ovl: allow zero size xattr
Subsystems (105)
From: Miklos Szeredi <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 97daf8b97ad6f913a34c82515be64dc9ac08d63e ]
When ovl_copy_xattr() encountered a zero size xattr no more xattrs were copied and the function returned success. This is clearly not the desired behavior.
--- fs/overlayfs/copy_up.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/copy_up.c +1 -1
@@ -54,7 +54,7 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new)for (name = buf; name < (buf + list_size); name +=strlen (name) +1 ) { size =vfs_getxattr (old, name, value,XATTR_SIZE_MAX ); -if (size <=0 ) { +if (size <0 ) { error = size; goto out_free_value; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] ovl: use a minimal buffer in ovl_copy_xattr
From: Vito Caputo <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e4ad29fa0d224d05e08b2858e65f112fd8edd4fe ]
Rather than always allocating the high-order XATTR_SIZE_MAX buffer which is costly and prone to failure, only allocate what is needed and realloc if necessary.
Fixes https://github.com/coreos/bugs/issues/489
--- fs/overlayfs/copy_up.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-)
fs/overlayfs/copy_up.c +25 -14
@@ -22,9 +22,9 @@int ovl_copy_xattr (struct dentry *old,struct dentry *new) { -ssize_t list_size, size; -char *buf, *name, *value; -int error; +ssize_t list_size, size, value_size =0 ; +char *buf, *name, *value =NULL ; +int uninitialized_var (error );if (!old->d_inode->i_op->getxattr || !new->d_inode->i_op->getxattr)
@@ -41,29 +41,40 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new)if (!buf)return -ENOMEM ; - error = -ENOMEM ; - value =kmalloc (XATTR_SIZE_MAX ,GFP_KERNEL ); -if (!value) - goto out; - list_size =vfs_listxattr (old, buf, list_size);if (list_size <=0 ) { error = list_size; - goto out_free_value; + goto out; }for (name = buf; name < (buf + list_size); name +=strlen (name) +1 ) { - size =vfs_getxattr (old, name, value,XATTR_SIZE_MAX ); +retry: + size =vfs_getxattr (old, name, value, value_size); +if (size == -ERANGE ) + size =vfs_getxattr (old, name,NULL ,0 ); +if (size <0 ) { error = size; - goto out_free_value; +break ; + } + +if (size > value_size) { +void *new; + + new =krealloc (value, size,GFP_KERNEL ); +if (!new) { + error = -ENOMEM ; +break ; + } + value = new; + value_size = size; + goto retry; } + error =vfs_setxattr (new, name, value, size,0 );if (error) - goto out_free_value; +break ; } - -out_free_value:kfree (value); out:kfree (buf);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] [media] media: dvb-core: Don't force CAN_INVERSION_AUTO in oneshot mode
In reply to Sasha LevinFrom: Malcolm Priestley <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c9d57de6103e343f2d4e04ea8d9e417e10a24da7 ]
When in FE_TUNE_MODE_ONESHOT the frontend must report the actual capabilities so user can take appropriate action.
With frontends that can't do auto inversion this is done by dvb-core automatically so CAN_INVERSION_AUTO is valid.
However, when in FE_TUNE_MODE_ONESHOT this is not true.
So only set FE_CAN_INVERSION_AUTO in modes other than FE_TUNE_MODE_ONESHOT
--- drivers/media/dvb-core/dvb_frontend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/dvb-core/dvb_frontend.c +3 -3
@@ -2333,9 +2333,9 @@ static int dvb_frontend_ioctl_legacy(struct file *file,dev_dbg (fe->dvb->device,"%s: current delivery system on cache: %d, V3 type: %d\n" , __func__, c->delivery_system, fe->ops.info.type); -/* Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't -* do it, it is done for it. */ - info->caps |=FE_CAN_INVERSION_AUTO ; +/* Set CAN_INVERSION_AUTO bit on in other than oneshot mode */ +if (!(fepriv->tune_mode_flags &FE_TUNE_MODE_ONESHOT )) + info->caps |=FE_CAN_INVERSION_AUTO ; err =0 ;break ; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] [media] vb2: fix a regression in poll() behavior for output,streams
In reply to Sasha LevinThis patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4623e5967448444a4ea1e77beb58898c4af48693 ]
In the 3.17 kernel the poll() behavior changed for output streams:
as long as not all buffers were queued up poll() would return that userspace can write. This is fine for the write() call, but when using stream I/O this changed the behavior since the expectation was that it would wait for buffers to become available for dequeuing.
This patch only enables the check whether you can queue buffers for file I/O only, and skips it for stream I/O.
--- drivers/media/v4l2-core/videobuf2-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/v4l2-core/videobuf2-core.c +3 -3
@@ -2662,10 +2662,10 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)return res |POLLERR ;/* -* For output streams you can write as long as there are fewer buffers -* queued than there are buffers available. +* For output streams you can call write() as long as there are fewer +* buffers queued than there are buffers available. */ -if (V4L2_TYPE_IS_OUTPUT (q->type) && q->queued_count < q->num_buffers) +if (V4L2_TYPE_IS_OUTPUT (q->type) && q->fileio && q->queued_count < q->num_buffers)return res |POLLOUT |POLLWRNORM ;if (list_empty (&q->done_list))
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] tools lib traceevent: Fix output of %llu for 64 bit values read on 32 bit machines
In reply to Sasha LevinFrom: Steven Rostedt <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 32abc2ede536aae52978d6c0a8944eb1df14f460 ]
When a long value is read on 32 bit machines for 64 bit output, the parsing needs to change "%lu" into "%llu", as the value is read natively.
Unfortunately, if "%llu" is already there, the code will add another "l" to it and fail to parse it properly.
--- tools/lib/traceevent/event-parse.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/lib/traceevent/event-parse.c +2 -3
@@ -4841,13 +4841,12 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event sizeof(long) != 8) {char *p; - ls =2 ;/* make %l into %ll */ - p =strchr (format,'l' ); -if (p) +if (ls ==1 && (p =strchr (format,'l' )))memmove (p+1 , p,strlen (p)+1 );else if (strcmp (format,"%p" ) ==0 )strcpy (format,"0x%llx" ); + ls =2 ; }switch (ls) {case -2 :
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] drm/radeon: call hpd_irq_event on resume
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit dbb17a21c131eca94eb31136eee9a7fe5aff00d9 ]
Need to call this on resume if displays changes during suspend in order to properly be notified of changes.
--- drivers/gpu/drm/radeon/radeon_device.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/radeon/radeon_device.c +1 -0
@@ -1734,6 +1734,7 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon) }drm_kms_helper_poll_enable (dev); +drm_helper_hpd_irq_event (dev);/* set the power state here in case we are a PX system or headless */ if ((rdev->pm.pm_method ==PM_METHOD_DPM ) && rdev->pm.dpm_enabled)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] ARM: mvebu: remove duplicated regulator definition in Armada 388 GP
In reply to Sasha LevinFrom: Thomas Petazzoni <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 079ae0c121fd23287f4ad2be9e9f8a13f63cae73 ]
The Armada 388 GP Device Tree file describes two times a regulator named 'reg_usb2_1_vbus', with the exact same description. This has been wrong since Armada 388 GP support was introduced.
--- arch/arm/boot/dts/armada-388-gp.dts | 10 ---------- 1 file changed, 10 deletions(-)
arch/arm/boot/dts/armada-388-gp.dts +0 -10
@@ -288,16 +288,6 @@ gpio = <&expander0 4 GPIO_ACTIVE_HIGH>; }; - reg_usb2_1_vbus: v5-vbus1 { - compatible = "regulator-fixed"; - regulator-name = "v5.0-vbus1"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - enable-active-high; - regulator-always-on; - gpio = <&expander0 4 GPIO_ACTIVE_HIGH>; - }; - reg_sata0: pwr-sata0 { compatible = "regulator-fixed"; regulator-name = "pwr_en_sata0";
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] ovl: root: copy attr
In reply to Sasha LevinFrom: Miklos Szeredi <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ed06e069775ad9236087594a1c1667367e983fb5 ]
We copy i_uid and i_gid of underlying inode into overlayfs inode. Except for the root inode.
Fix this omission.
--- fs/overlayfs/super.c | 3 +++ 1 file changed, 3 insertions(+)
fs/overlayfs/super.c +3 -0
@@ -986,6 +986,9 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) root_dentry->d_fsdata = oe; +ovl_copyattr (ovl_dentry_real (root_dentry)->d_inode, + root_dentry->d_inode); + sb->s_magic =OVERLAYFS_SUPER_MAGIC ; sb->s_op = &ovl_super_operations; sb->s_root = root_dentry;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] time: Avoid signed overflow in timekeeping_get_ns()
In reply to Sasha LevinFrom: David Gibson <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 35a4933a895927990772ae96fdcfd2f806929ee2 ]
1e75fa8 "time: Condense timekeeper.xtime into xtime_sec" replaced a call to clocksource_cyc2ns() from timekeeping_get_ns() with an open-coded version of the same logic to avoid keeping a semi-redundant struct timespec in struct timekeeper.
However, the commit also introduced a subtle semantic change - where clocksource_cyc2ns() uses purely unsigned math, the new version introduces a signed temporary, meaning that if (delta * tk->mult) has a 63-bit overflow the following shift will still give a negative result. The choice of 'maxsec' in __clocksource_updatefreq_scale() means this will generally happen if there's a ~10 minute pause in examining the clocksource.
This can be triggered on a powerpc KVM guest by stopping it from qemu for a bit over 10 minutes. After resuming time has jumped backwards several minutes causing numerous problems (jiffies does not advance, msleep()s can be extended by minutes..). It doesn't happen on x86 KVM guests, because the guest TSC is effectively frozen while the guest is stopped, which is not the case for the powerpc timebase.
Obviously an unsigned (64 bit) overflow will only take twice as long as a signed, 63-bit overflow. I don't know the time code well enough to know if that will still cause incorrect calculations, or if a 64-bit overflow is avoided elsewhere.
Still, an incorrect forwards clock adjustment will cause less trouble than time going backwards. So, this patch removes the potential for intermediate signed overflow.
--- kernel/time/timekeeping.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/time/timekeeping.c +1 -2
@@ -316,8 +316,7 @@ static inline s64 timekeeping_get_ns(struct tk_read_base *tkr) delta =timekeeping_get_delta (tkr); - nsec = delta * tkr->mult + tkr->xtime_nsec; - nsec >>= tkr->shift; + nsec = (delta * tkr->mult + tkr->xtime_nsec) >> tkr->shift;/* If arch requires, add in get_arch_timeoffset() */ return nsec +arch_gettimeoffset ();
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] ovl: setattr: check permissions before copy-up
In reply to Sasha LevinFrom: Miklos Szeredi <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cf9a6784f7c1b5ee2b9159a1246e327c331c5697 ]
Without this copy-up of a file can be forced, even without actually being allowed to do anything on the file.
[Arnd Bergmann] include <linux/pagemap.h> for PAGE_CACHE_SIZE (used by MAX_LFS_FILESIZE definition).
--- fs/overlayfs/inode.c | 13 +++++++++++++ fs/overlayfs/super.c | 2 ++ 2 files changed, 15 insertions(+)
fs/overlayfs/inode.c +13 -0
@@ -45,6 +45,19 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)int err;struct dentry *upperdentry; +/* +* Check for permissions before trying to copy-up. This is redundant +* since it will be rechecked later by ->setattr() on upper dentry. But +* without this, copy-up can be triggered by just about anybody. +* +* We don't initialize inode->size, which just means that +* inode_newsize_ok() will always check against MAX_LFS_FILESIZE and not +* check for a swapfile (which this won't be anyway). +*/ + err =inode_change_ok (dentry->d_inode, attr); +if (err) +return err; + err =ovl_want_write (dentry);if (err) goto out;
fs/overlayfs/super.c +2 -0
@@ -9,6 +9,7 @@#include <linux/fs.h> #include <linux/namei.h> +#include <linux/pagemap.h> #include <linux/xattr.h> #include <linux/security.h> #include <linux/mount.h>
@@ -847,6 +848,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) } sb->s_stack_depth =0 ; + sb->s_maxbytes =MAX_LFS_FILESIZE ;if (ufs->config.upperdir) {if (!ufs->config.workdir) {pr_err ("overlayfs: missing 'workdir'\n" );
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] drm: Don't overwrite UNVERFIED mode status to OK
In reply to Sasha LevinFrom: Ville Syrjälä <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit be8719a610003297c28b140f1ebd4445aef1d613 ]
The way the mode probing works is this:
1. All modes currently on the mode list are marked as UNVERIFIED
2. New modes are on the probed_modes list (they start with status OK)
3. Modes are moved from the probed_modes list to the actual mode list. If a mode already on the mode list is deemed to match one of the probed modes, the duplicate is dropped and the mode status updated to OK. After this the probed_modes list will be empty.
4. All modes on the mode list are verified to not violate any constraints. Any that do are marked as such.
5. Any mode left with a non-OK status is pruned from the list, with an appropriate debug message.
What all this means is that any mode on the original list that didn't have a duplicate on the probed_modes list, should be left with status UNVERFIED (or previously could have been left with some other status, but never OK).
I broke that in
commit 05acaec334fc ("drm: Reorganize probed mode validation") by always assigning something to the mode->status during the validation step. So any mode from the old list that still passed the validation would be left on the list with status OK in the end.
Fix this by not doing the basic mode validation unless the mode already has status OK (meaning it came from the probed_modes list, or at least a duplicate of it was on that list). This way we will correctly prune away any mode from the old mode list that didn't appear on the probed_modes list.
Testcase: igt/kms_force_connector_basic/prune-stale-modes
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93332
[danvet: Also applying to drm-misc to avoid too much conflict hell - there's a big pile of patches from Ville on top of this one.]
--- drivers/gpu/drm/drm_probe_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_probe_helper.c +2 -1
@@ -195,7 +195,8 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect mode_flags |=DRM_MODE_FLAG_3D_MASK ;list_for_each_entry (mode, &connector->modes, head) { - mode->status =drm_mode_validate_basic (mode); +if (mode->status ==MODE_OK ) + mode->status =drm_mode_validate_basic (mode);if (mode->status ==MODE_OK ) mode->status =drm_mode_validate_size (mode, maxX, maxY);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] ovl: check dentry positiveness in ovl_cleanup_whiteouts()
In reply to Sasha LevinFrom: Konstantin Khlebnikov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 84889d49335627bc770b32787c1ef9ebad1da232 ]
This patch fixes kernel crash at removing directory which contains whiteouts from lower layers.
Cache of directory content passed as "list" contains entries from all layers, including whiteouts from lower layers. So, lookup in upper dir (moved into work at this stage) will return negative entry. Plus this cache is filled long before and we can race with external removal.
Example:
mkdir -p lower0/dir lower1/dir upper work overlay
touch lower0/dir/a lower0/dir/b
mknod lower1/dir/a c 0 0
mount -t overlay none overlay -o lowerdir=lower1:lower0,upperdir=upper,workdir=work rm -fr overlay/dir
--- fs/overlayfs/readdir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/overlayfs/readdir.c +2 -1
@@ -571,7 +571,8 @@ void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list) (int) PTR_ERR(dentry));continue ; } -ovl_cleanup (upper->d_inode, dentry); +if (dentry->d_inode) +ovl_cleanup (upper->d_inode, dentry);dput (dentry); }mutex_unlock (&upper->d_inode->i_mutex);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] [media] gspca: ov534/topro: prevent a division by 0
In reply to Sasha LevinFrom: Antonio Ospite <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit dcc7fdbec53a960588f2c40232db2c6466c09917 ]
v4l2-compliance sends a zeroed struct v4l2_streamparm in v4l2-test-formats.cpp::testParmType(), and this results in a division by 0 in some gspca subdrivers:
divide error: 0000 [#1] SMP
Modules linked in: gspca_ov534 gspca_main ...
CPU: 0 PID: 17201 Comm: v4l2-compliance Not tainted 4.3.0-rc2-ao2 #1
Hardware name: System manufacturer System Product Name/M2N-E SLI, BIOS
ASUS M2N-E SLI ACPI BIOS Revision 1301 09/16/2010
task: ffff8800818306c0 ti: ffff880095c4c000 task.ti: ffff880095c4c000
RIP: 0010:[<ffffffffa079bd62>] [<ffffffffa079bd62>] sd_set_streamparm+0x12/0x60 [gspca_ov534]
RSP: 0018:ffff880095c4fce8 EFLAGS: 00010296
RAX: 0000000000000000 RBX: ffff8800c9522000 RCX: ffffffffa077a140
RDX: 0000000000000000 RSI: ffff880095e0c100 RDI: ffff8800c9522000
RBP: ffff880095e0c100 R08: ffffffffa077a100 R09: 00000000000000cc
R10: ffff880067ec7740 R11: 0000000000000016 R12: ffffffffa07bb400
R13: 0000000000000000 R14: ffff880081b6a800 R15: 0000000000000000
FS: 00007fda0de78740(0000) GS:ffff88012fc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000014630f8 CR3: 00000000cf349000 CR4: 00000000000006f0
Stack:
ffffffffa07a6431 ffff8800c9522000 ffffffffa077656e 00000000c0cc5616
ffff8800c9522000 ffffffffa07a5e20 ffff880095e0c100 0000000000000000
ffff880067ec7740 ffffffffa077a140 ffff880067ec7740 0000000000000016
Call Trace:
[<ffffffffa07a6431>] ? v4l_s_parm+0x21/0x50 [videodev]
[<ffffffffa077656e>] ? vidioc_s_parm+0x4e/0x60 [gspca_main]
[<ffffffffa07a5e20>] ? __video_do_ioctl+0x280/0x2f0 [videodev]
[<ffffffffa07a5ba0>] ? video_ioctl2+0x20/0x20 [videodev]
[<ffffffffa07a59b9>] ? video_usercopy+0x319/0x4e0 [videodev]
[<ffffffff81182dc1>] ? page_add_new_anon_rmap+0x71/0xa0
[<ffffffff811afb92>] ? mem_cgroup_commit_charge+0x52/0x90
[<ffffffff81179b18>] ? handle_mm_fault+0xc18/0x1680
[<ffffffffa07a15cc>] ? v4l2_ioctl+0xac/0xd0 [videodev]
[<ffffffff811c846f>] ? do_vfs_ioctl+0x28f/0x480
[<ffffffff811c86d4>] ? SyS_ioctl+0x74/0x80
[<ffffffff8154a8b6>] ? entry_SYSCALL_64_fastpath+0x16/0x75
Code: c7 93 d9 79 a0 5b 5d e9 f1 f3 9a e0 0f 1f 00 66 2e 0f 1f 84 00
00 00 00 00 66 66 66 66 90 53 31 d2 48 89 fb 48 83 ec 08 8b 46 10 <f7>
76 0c 80 bf ac 0c 00 00 00 88 87 4e 0e 00 00 74 09 80 bf 4f
RIP [<ffffffffa079bd62>] sd_set_streamparm+0x12/0x60 [gspca_ov534]
RSP <ffff880095c4fce8>
---[ end trace 279710c2c6c72080 ]---Following what the doc says about a zeroed timeperframe (see
http://www.linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-parm.html):
...
To reset manually applications can just set this field to zero.
fix the issue by resetting the frame rate to a default value in case of an unusable timeperframe.
The fix is done in the subdrivers instead of gspca.c because only the subdrivers have notion of a default frame rate to reset the camera to.
--- drivers/media/usb/gspca/ov534.c | 9 +++++++-- drivers/media/usb/gspca/topro.c | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-)
drivers/media/usb/gspca/ov534.c +7 -2
@@ -1491,8 +1491,13 @@ static void sd_set_streamparm(struct gspca_dev *gspca_dev,struct v4l2_fract *tpf = &cp->timeperframe;struct sd *sd = (struct sd *) gspca_dev; -/* Set requested framerate */ - sd->frame_rate = tpf->denominator / tpf->numerator; +if (tpf->numerator ==0 || tpf->denominator ==0 ) +/* Set default framerate */ + sd->frame_rate =30 ; +else +/* Set requested framerate */ + sd->frame_rate = tpf->denominator / tpf->numerator; +if (gspca_dev->streaming)set_frame_rate (gspca_dev);
drivers/media/usb/gspca/topro.c +5 -1
@@ -4802,7 +4802,11 @@ static void sd_set_streamparm(struct gspca_dev *gspca_dev,struct v4l2_fract *tpf = &cp->timeperframe;int fr, i; - sd->framerate = tpf->denominator / tpf->numerator; +if (tpf->numerator ==0 || tpf->denominator ==0 ) + sd->framerate =30 ; +else + sd->framerate = tpf->denominator / tpf->numerator; +if (gspca_dev->streaming)setframerate (gspca_dev,v4l2_ctrl_g_ctrl (gspca_dev->exposure));
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] Bluetooth: Add support of Toshiba Broadcom based devices
In reply to Sasha LevinFrom: Dmitry Tunin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1623d0bf847d3b38d8cf24367b3689ba0e3fe2aa ]
T: Bus=03 Lev=02 Prnt=02 Port=05 Cnt=02 Dev#= 4 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=0930 ProdID=0225 Rev=01.12
S: Manufacturer=Broadcom Corp
S: Product=BCM43142A0
S: SerialNumber=4CBB58034671
C: #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)--- drivers/bluetooth/btusb.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/bluetooth/btusb.c +4 -0
@@ -144,6 +144,10 @@ static const struct usb_device_id btusb_table[] = { { USB_VENDOR_AND_INTERFACE_INFO(0x13d3, 0xff, 0x01, 0x01), .driver_info = BTUSB_BCM_PATCHRAM }, + /* Toshiba Corp - Broadcom based */ + { USB_VENDOR_AND_INTERFACE_INFO(0x0930, 0xff, 0x01, 0x01), + .driver_info = BTUSB_BCM_PATCHRAM }, + /* Intel Bluetooth USB Bootloader (RAM module) */ { USB_DEVICE(0x8087, 0x0a5a), .driver_info = BTUSB_INTEL_BOOT | BTUSB_BROKEN_ISOC },
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] EDAC, mc_sysfs: Fix freeing bus' name
In reply to Sasha LevinFrom: Borislav Petkov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 12e26969b32c79018165d52caff3762135614aa1 ]
I get the splat below when modprobing/rmmoding EDAC drivers. It happens because bus->name is invalid after bus_unregister() has run. The Code: section below corresponds to:
.loc 1 1108 0
movq 672(%rbx), %rax # mci_1(D)->bus, mci_1(D)->bus
.loc 1 1109 0
popq %rbx #
.loc 1 1108 0
movq (%rax), %rdi # _7->name,
jmp kfree #
and %rax has some funky stuff 2030203020312030 which looks a lot like something walked over it.
Fix that by saving the name ptr before doing stuff to string it points to.
general protection fault: 0000 [#1] SMP
Modules linked in: ...
CPU: 4 PID: 10318 Comm: modprobe Tainted: G I EN 3.12.51-11-default+ #48
Hardware name: HP ProLiant DL380 G7, BIOS P67 05/05/2011
task: ffff880311320280 ti: ffff88030da3e000 task.ti: ffff88030da3e000
RIP: 0010:[<ffffffffa019da92>] [<ffffffffa019da92>] edac_unregister_sysfs+0x22/0x30 [edac_core]
RSP: 0018:ffff88030da3fe28 EFLAGS: 00010292
RAX: 2030203020312030 RBX: ffff880311b4e000 RCX: 000000000000095c
RDX: 0000000000000001 RSI: ffff880327bb9600 RDI: 0000000000000286
RBP: ffff880311b4e750 R08: 0000000000000000 R09: ffffffff81296110
R10: 0000000000000400 R11: 0000000000000000 R12: ffff88030ba1ac68
R13: 0000000000000001 R14: 00000000011b02f0 R15: 0000000000000000
FS: 00007fc9bf8f5700(0000) GS:ffff8801a7c40000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 0000000000403c90 CR3: 000000019ebdf000 CR4: 00000000000007e0
Stack:
Call Trace:
i7core_unregister_mci.isra.9
i7core_remove
pci_device_remove
__device_release_driver
driver_detach
bus_remove_driver
pci_unregister_driver
i7core_exit
SyS_delete_module
system_call_fastpath
0x7fc9bf426536
Code: 2e 0f 1f 84 00 00 00 00 00 66 66 66 66 90 53 48 89 fb e8 52 2a 1f e1 48 8b bb a0 02 00 00 e8 46 59 1f e1 48 8b 83 a0 02 00 00 5b <48> 8b 38 e9 26 9a fe e0 66 0f 1f 44 00 00 66 66 66 66 90 48 8b
RIP [<ffffffffa019da92>] edac_unregister_sysfs+0x22/0x30 [edac_core]
RSP <ffff88030da3fe28>--- drivers/edac/edac_mc_sysfs.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/edac/edac_mc_sysfs.c +14 -7
@@ -977,21 +977,26 @@ nomem:int edac_create_sysfs_mci_device (struct mem_ctl_info *mci,const struct attribute_group **groups) { +char *name;int i, err;/* * The memory controller needs its own bus, in order to avoid * namespace conflicts at /sys/bus/edac. */ - mci->bus->name =kasprintf (GFP_KERNEL ,"mc%d" , mci->mc_idx); -if (!mci->bus->name) + name =kasprintf (GFP_KERNEL ,"mc%d" , mci->mc_idx); +if (!name)return -ENOMEM ; + mci->bus->name = name; +edac_dbg (0 ,"creating bus %s\n" , mci->bus->name); err =bus_register (mci->bus); -if (err <0 ) - goto fail_free_name; +if (err <0 ) { +kfree (name); +return err; + }/* get the /sys/devices/system/edac subsys reference */ mci->dev.type = &mci_attr_type;
@@ -1060,8 +1065,8 @@ fail_unregister_dimm:device_unregister (&mci->dev); fail_unregister_bus:bus_unregister (mci->bus); -fail_free_name: -kfree (mci->bus->name); +kfree (name); +return err; }
@@ -1092,10 +1097,12 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)void edac_unregister_sysfs (struct mem_ctl_info *mci) { +const char *name = mci->bus->name; +edac_dbg (1 ,"Unregistering device %s\n" ,dev_name (&mci->dev));device_unregister (&mci->dev);bus_unregister (mci->bus); -kfree (mci->bus->name); +kfree (name); }static void mc_attr_release (struct device *dev)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] rtlwifi: fix memory leak for USB device
In reply to Sasha LevinFrom: Peter Wu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 17bc55864f81dd730d05f09b1641312a7990d636 ]
Free skb for received frames with a wrong checksum. This can happen pretty rapidly, exhausting all memory.
This fixes a memleak (detected with kmemleak). Originally found while using monitor mode, but it also appears during managed mode (once the link is up).
--- drivers/net/wireless/rtlwifi/usb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/rtlwifi/usb.c +2 -0
@@ -531,6 +531,8 @@ static void _rtl_usb_rx_process_noagg(struct ieee80211_hw *hw,ieee80211_rx (hw, skb); elsedev_kfree_skb_any (skb ); + }else { +dev_kfree_skb_any (skb); } }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] EDAC: Robustify workqueues destruction
In reply to Sasha LevinFrom: Borislav Petkov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fcd5c4dd8201595d4c598c9cca5e54760277d687 ]
EDAC workqueue destruction is really fragile. We cancel delayed work but if it is still running and requeues itself, we still go ahead and destroy the workqueue and the queued work explodes when workqueue core attempts to run it.
Make the destruction more robust by switching op_state to offline so that requeuing stops. Cancel any pending work *synchronously* too.
EDAC i7core: Driver loaded.
general protection fault: 0000 [#1] SMP CPU 12 Modules linked in: Supported: Yes Pid: 0, comm: kworker/0:1 Tainted: G IE 3.0.101-0-default #1 HP ProLiant DL380 G7 RIP: 0010:[<ffffffff8107dcd7>] [<ffffffff8107dcd7>] __queue_work+0x17/0x3f0 < ... regs ...> Process kworker/0:1 (pid: 0, threadinfo ffff88019def6000, task ffff88019def4600) Stack: ... Call Trace: call_timer_fn run_timer_softirq __do_softirq call_softirq do_softirq irq_exit smp_apic_timer_interrupt apic_timer_interrupt intel_idle cpuidle_idle_call cpu_idle Code: ... RIP __queue_work RSP <...>
--- drivers/edac/edac_device.c | 11 ++++------- drivers/edac/edac_mc.c | 14 +++----------- drivers/edac/edac_pci.c | 9 ++++----- 3 files changed, 11 insertions(+), 23 deletions(-)
drivers/edac/edac_device.c +4 -7
@@ -435,16 +435,13 @@ void edac_device_workq_setup(struct edac_device_ctl_info *edac_dev,*/ void edac_device_workq_teardown (struct edac_device_ctl_info *edac_dev) { -int status; -if (!edac_dev->edac_check)return ; - status =cancel_delayed_work (&edac_dev->work); -if (status ==0 ) { -/* workq instance might be running, wait for it */ -flush_workqueue (edac_workqueue); - } + edac_dev->op_state =OP_OFFLINE ; + +cancel_delayed_work_sync (&edac_dev->work); +flush_workqueue (edac_workqueue); }/*
drivers/edac/edac_mc.c +3 -11
@@ -581,18 +581,10 @@ static void edac_mc_workq_setup(struct mem_ctl_info *mci, unsigned msec,*/ static void edac_mc_workq_teardown (struct mem_ctl_info *mci) { -int status; - -if (mci->op_state !=OP_RUNNING_POLL ) -return ; - - status =cancel_delayed_work (&mci->work); -if (status ==0 ) { -edac_dbg (0 ,"not canceled, flush the queue\n" ); + mci->op_state =OP_OFFLINE ; -/* workq instance might be running, wait for it */ -flush_workqueue (edac_workqueue); - } +cancel_delayed_work_sync (&mci->work); +flush_workqueue (edac_workqueue); }/*
drivers/edac/edac_pci.c +4 -5
@@ -274,13 +274,12 @@ static void edac_pci_workq_setup(struct edac_pci_ctl_info *pci,*/ static void edac_pci_workq_teardown (struct edac_pci_ctl_info *pci) { -int status; -edac_dbg (0 ,"\n" ); - status =cancel_delayed_work (&pci->work); -if (status ==0 ) -flush_workqueue (edac_workqueue); + pci->op_state =OP_OFFLINE ; + +cancel_delayed_work_sync (&pci->work); +flush_workqueue (edac_workqueue); }/*
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] KVM: PPC: Fix emulation of H_SET_DABR/X on POWER8
In reply to Sasha LevinFrom: Thomas Huth <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 760a7364f27d974d100118d88190e574626e18a6 ]
In the old DABR register, the BT (Breakpoint Translation) bit is bit number 61. In the new DAWRX register, the WT (Watchpoint Translation) bit is bit number 59. So to move the DABR-BT bit into the position of the DAWRX-WT bit, it has to be shifted by two, not only by one. This fixes hardware watchpoints in gdb of older guests that only use the H_SET_DABR/X interface instead of the new H_SET_MODE interface.
--- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/book3s_hv_rmhandlers.S +1 -1
@@ -2047,7 +2047,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) /* Emulate H_SET_DABR/X on P8 for the sake of compat mode guests */ 2: rlwimi r5, r4, 5, DAWRX_DR | DAWRX_DW - rlwimi r5, r4, 1, DAWRX_WT + rlwimi r5, r4, 2, DAWRX_WT clrrdi r4, r4, 3 std r4, VCPU_DAWR(r3) std r5, VCPU_DAWRX(r3)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] drm/radeon: Fix "slow" audio over DP on DCE8+
In reply to Sasha LevinFrom: Slava Grigorev <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ac4a9350abddc51ccb897abf0d9f3fd592b97e0b ]
DP audio is derived from the dfs clock.
--- drivers/gpu/drm/radeon/dce6_afmt.c | 16 ++++++++++++++++ drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_atombios.c | 7 +++++++ drivers/gpu/drm/radeon/sid.h | 5 +++++ 4 files changed, 29 insertions(+)
drivers/gpu/drm/radeon/dce6_afmt.c +16 -0
@@ -282,6 +282,22 @@ void dce6_dp_audio_set_dto(struct radeon_device *rdev,* is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator */ if (ASIC_IS_DCE8 (rdev)) { +unsigned int div = (RREG32 (DENTIST_DISPCLK_CNTL ) & +DENTIST_DPREFCLK_WDIVIDER_MASK ) >> +DENTIST_DPREFCLK_WDIVIDER_SHIFT ; + +if (div <128 && div >=96 ) + div -=64 ; +else if (div >=64 ) + div = div /2 -16 ; +else if (div >=8 ) + div /=4 ; +else + div =0 ; + +if (div) + clock = rdev->clock.gpupll_outputfreq *10 / div; +WREG32 (DCE8_DCCG_AUDIO_DTO1_PHASE ,24000 );WREG32 (DCE8_DCCG_AUDIO_DTO1_MODULE , clock); }else {
drivers/gpu/drm/radeon/radeon.h +1 -0
@@ -268,6 +268,7 @@ struct radeon_clock {uint32_t current_dispclk;uint32_t dp_extclk;uint32_t max_pixel_clock; +uint32_t gpupll_outputfreq; };/*
drivers/gpu/drm/radeon/radeon_atombios.c +7 -0
@@ -1263,6 +1263,13 @@ bool radeon_atom_get_clock_info(struct drm_device *dev) rdev->mode_info.firmware_flags =le16_to_cpu (firmware_info->info.usFirmwareCapability.susAccess); +if (ASIC_IS_DCE8 (rdev)) { + rdev->clock.gpupll_outputfreq = +le32_to_cpu (firmware_info->info_22.ulGPUPLL_OutputFreq); +if (rdev->clock.gpupll_outputfreq ==0 ) + rdev->clock.gpupll_outputfreq =360000 ;/* 3.6 GHz */ + } +return true; }
drivers/gpu/drm/radeon/sid.h +5 -0
@@ -915,6 +915,11 @@#define DCCG_AUDIO_DTO1_PHASE 0x05c0#define DCCG_AUDIO_DTO1_MODULE 0x05c4 +#define DENTIST_DISPCLK_CNTL 0x0490 +# define DENTIST_DPREFCLK_WDIVIDER (x) (((x) & 0x7f) << 24) +# define DENTIST_DPREFCLK_WDIVIDER_MASK (0x7f << 24) +# define DENTIST_DPREFCLK_WDIVIDER_SHIFT 24 +#define AFMT_AUDIO_SRC_CONTROL 0x713c#define AFMT_AUDIO_SRC_SELECT (x) (((x) & 7) << 0)/* AFMT_AUDIO_SRC_SELECT
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] iommu/io-pgtable-arm: Ensure we free the final level on teardown
In reply to Sasha LevinFrom: Will Deacon <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 12c2ab09571e8aae3a87da2a4a452632a5fac1e5 ]
When tearing down page tables, we return early for the final level since we know that we won't have any table pointers to follow. Unfortunately, this also means that we forget to free the final level, so we end up leaking memory.
Fix the issue by always freeing the current level, but just don't bother to iterate over the ptes if we're at the final level.
--- drivers/iommu/io-pgtable-arm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/iommu/io-pgtable-arm.c +6 -5
@@ -341,17 +341,18 @@ static void __arm_lpae_free_pgtable(struct arm_lpae_io_pgtable *data, int lvl,arm_lpae_iopte *start, *end;unsigned long table_size; -/* Only leaf entries at the last level */ -if (lvl ==ARM_LPAE_MAX_LEVELS -1 ) -return ; -if (lvl ==ARM_LPAE_START_LVL (data)) table_size = data->pgd_size;else table_size =1UL << data->pg_shift; start = ptep; - end = (void *)ptep + table_size; + +/* Only leaf entries at the last level */ +if (lvl ==ARM_LPAE_MAX_LEVELS -1 ) + end = ptep; +else + end = (void *)ptep + table_size;while (ptep != end) {arm_lpae_iopte pte = *ptep++;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] drm/radeon: clean up fujitsu quirks
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0eb1c3d4084eeb6fb3a703f88d6ce1521f8fcdd1 ]
Combine the two quirks.
bug:
https://bugzilla.kernel.org/show_bug.cgi?id=109481
--- drivers/gpu/drm/radeon/radeon_atombios.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/radeon/radeon_atombios.c +3 -9
@@ -437,7 +437,9 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev, }/* Fujitsu D3003-S2 board lists DVI-I as DVI-D and VGA */ -if (((dev->pdev->device ==0x9802 ) || (dev->pdev->device ==0x9806 )) && +if (((dev->pdev->device ==0x9802 ) || + (dev->pdev->device ==0x9805 ) || + (dev->pdev->device ==0x9806 )) && (dev->pdev->subsystem_vendor ==0x1734 ) && (dev->pdev->subsystem_device ==0x11bd )) {if (*connector_type ==DRM_MODE_CONNECTOR_VGA ) {
@@ -448,14 +450,6 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev, } } -/* Fujitsu D3003-S2 board lists DVI-I as DVI-I and VGA */ -if ((dev->pdev->device ==0x9805 ) && - (dev->pdev->subsystem_vendor ==0x1734 ) && - (dev->pdev->subsystem_device ==0x11bd )) { -if (*connector_type ==DRM_MODE_CONNECTOR_VGA ) -return false; - } -return true; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] mmc: sdio: Fix invalid vdd in voltage switch power cycle
In reply to Sasha LevinFrom: Adrian Hunter <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d9bfbb95ed598a09cf336adb0f190ee0ff802f0d ]
The 'ocr' parameter passed to mmc_set_signal_voltage() defines the power-on voltage used when power cycling after a failure to set the voltage. However, in the case of mmc_sdio_init_card(), the value passed has the R4_18V_PRESENT flag set which is not valid for power-on and results in an invalid vdd. Fix by passing the card's ocr value which does not have the flag.
--- drivers/mmc/core/sdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/sdio.c +1 -1
@@ -661,7 +661,7 @@ try_again:*/ if (!powered_resume && (rocr & ocr &R4_18V_PRESENT )) { err =mmc_set_signal_voltage (host,MMC_SIGNAL_VOLTAGE_180 , - ocr); + ocr_card);if (err == -EAGAIN ) {sdio_reset (host);mmc_go_idle (host);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] coresight: checking for NULL string in coresight_name_match()
In reply to Sasha LevinFrom: Mathieu Poirier <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fadf3a44e974b030e7145218ad1ab25e3ef91738 ]
Connection child names associated to ports can sometimes be NULL, which is the case when booting a system on QEMU or when the Coresight power domain isn't switched on.
This patch is adding a check to make sure a NULL string isn't fed to strcmp(), something that avoid crashing the system.
--- drivers/hwtracing/coresight/coresight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight.c +1 -1
@@ -543,7 +543,7 @@ static int coresight_name_match(struct device *dev, void *data) to_match = data; i_csdev =to_coresight_device (dev); -if (!strcmp (to_match,dev_name (&i_csdev->dev))) +if (to_match && !strcmp (to_match,dev_name (&i_csdev->dev)))return 1 ;return 0 ;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] drm/radeon: Fix off-by-one errors in radeon_vm_bo_set_addr
In reply to Sasha LevinFrom: Felix Kuehling <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 42ef344c0994cc453477afdc7a8eadc578ed0257 ]
eoffset is sometimes treated as the last address inside the address range, and sometimes as the first address outside the range. This was resulting in errors when a test filled up the entire address space. Make it consistent to always be the last address within the range. Also fixed related errors when checking the VA limit and in radeon_vm_fence_pts.
--- drivers/gpu/drm/radeon/radeon_vm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/radeon/radeon_vm.c +6 -6
@@ -456,15 +456,15 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,if (soffset) {/* make sure object fit at this offset */ - eoffset = soffset + size; + eoffset = soffset + size -1 ;if (soffset >= eoffset) { r = -EINVAL ; goto error_unreserve; } last_pfn = eoffset /RADEON_GPU_PAGE_SIZE ; -if (last_pfn > rdev->vm_manager.max_pfn) { -dev_err (rdev->dev,"va above limit (0x%08X > 0x%08X)\n" , +if (last_pfn >= rdev->vm_manager.max_pfn) { +dev_err (rdev->dev,"va above limit (0x%08X >= 0x%08X)\n" , last_pfn, rdev->vm_manager.max_pfn); r = -EINVAL ; goto error_unreserve;
@@ -479,7 +479,7 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev, eoffset /=RADEON_GPU_PAGE_SIZE ;if (soffset || eoffset) {struct interval_tree_node *it; - it =interval_tree_iter_first (&vm->va, soffset, eoffset -1 ); + it =interval_tree_iter_first (&vm->va, soffset, eoffset);if (it && it != &bo_va->it) {struct radeon_bo_va *tmp; tmp = container_of(it, struct radeon_bo_va, it);
@@ -522,7 +522,7 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,if (soffset || eoffset) { bo_va->it.start = soffset; - bo_va->it.last = eoffset -1 ; + bo_va->it.last = eoffset;interval_tree_insert (&bo_va->it, &vm->va); }
@@ -891,7 +891,7 @@ static void radeon_vm_fence_pts(struct radeon_vm *vm,unsigned i; start >>= radeon_vm_block_size; - end >>= radeon_vm_block_size; + end = (end -1 ) >> radeon_vm_block_size;for (i = start; i <= end; ++i)radeon_bo_fence (vm->page_tables[i].bo, fence, true);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] mmc: sdhci: Fix DMA descriptor with zero data length
In reply to Sasha LevinFrom: Adrian Hunter <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 347ea32dc118326c4f2636928239a29d192cc9b8 ]
SDHCI has built-in DMA called ADMA2. ADMA2 uses a descriptor table to define DMA scatter-gather. Each desciptor can specify a data length up to 65536 bytes, however the length field is only 16-bits so zero means 65536. Consequently, putting zero when the size is zero must not be allowed. This patch fixes one case where zero data length could be set inadvertently.
The problem happens because unaligned data gets split and the code did not consider that the remaining aligned portion might be zero length. That case really only happens for SDIO because SD and eMMC cards transfer blocks that are invariably sector- aligned. For SDIO, access to function registers is done by data transfer (CMD53) when the register is bigger than 1 byte. Generally registers are 4 bytes but 2-byte registers are possible. So DMA of 4 bytes or less can happen. When 32-bit DMA is used, the data alignment must be 4, so 4-byte transfers won't casue a problem, but a 2-byte transfer could. However with the introduction of 64-bit DMA, the data alignment for 64-bit DMA was made 8 bytes, so all 4-byte transfers not on 8-byte boundaries get "split" into a 4-byte chunk and a 0-byte chunk, thereby hitting the bug.
In fact, a closer look at the SDHCI specs indicates that only the descriptor table requires 8-byte alignment for 64-bit DMA. That will be dealt with in a separate patch, but the potential for a 2-byte access remains, so this fix is needed anyway.
--- drivers/mmc/host/sdhci.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci.c +6 -3
@@ -555,9 +555,12 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,BUG_ON (len >65536 ); -/* tran, valid */ -sdhci_adma_write_desc (host, desc, addr, len,ADMA2_TRAN_VALID ); - desc += host->desc_sz; +if (len) { +/* tran, valid */ +sdhci_adma_write_desc (host, desc, addr, len, +ADMA2_TRAN_VALID ); + desc += host->desc_sz; + }/* * If this triggers then we have a calculation bug
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] mmc: sdhci: Fix sdhci_runtime_pm_bus_on/off()
In reply to Sasha LevinFrom: Adrian Hunter <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5c671c410c8704800f4f1673b6f572137e7e6ddd ]
sdhci has a legacy facility to prevent runtime suspend if the bus power is on. This is needed in cases where the power to the card is dependent on the bus power. It is controlled by a pair of functions: sdhci_runtime_pm_bus_on() and sdhci_runtime_pm_bus_off(). These functions use a boolean variable 'bus_on' to ensure changes are always paired. There is an additional check for 'runtime_suspended' which is the problem. In fact, its use is ill-conceived as the only requirement for the logic is that 'on' and 'off' are paired, which is actually broken by the check, for example if the bus power is turned on during runtime resume. So remove the check.
--- drivers/mmc/host/sdhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +2 -2
@@ -2793,7 +2793,7 @@ static int sdhci_runtime_pm_put(struct sdhci_host *host)static void sdhci_runtime_pm_bus_on (struct sdhci_host *host) { -if (host->runtime_suspended || host->bus_on) +if (host->bus_on)return ; host->bus_on = true;pm_runtime_get_noresume (host->mmc->parent);
@@ -2801,7 +2801,7 @@ static void sdhci_runtime_pm_bus_on(struct sdhci_host *host)static void sdhci_runtime_pm_bus_off (struct sdhci_host *host) { -if (host->runtime_suspended || !host->bus_on) +if (!host->bus_on)return ; host->bus_on = false;pm_runtime_put_noidle (host->mmc->parent);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] arm64: mdscr_el1: avoid exposing DCC to userspace
In reply to Sasha LevinFrom: Will Deacon <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d8d23fa0f27f3b2942a7bbc7378c7735324ed519 ]
We don't want to expose the DCC to userspace, particularly as there is a kernel console driver for it.
This patch resets mdscr_el1 to disable userspace access to the DCC registers on the cold boot path.
--- arch/arm64/mm/proc.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/mm/proc.S +2 -1
@@ -202,7 +202,8 @@ ENTRY(__cpu_setup) mov x0, #3 << 20 msr cpacr_el1, x0 // Enable FP/ASIMD - msr mdscr_el1, xzr // Reset mdscr_el1 + mov x0, #1 << 12 // Reset mdscr_el1 and disable + msr mdscr_el1, x0 // access to the DCC from EL0 /* * Memory region attributes for LPAE: *
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] arm64: kernel: enforce pmuserenr_el0 initialization and restore
In reply to Sasha LevinFrom: Lorenzo Pieralisi <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d2d39a3b91628ef5abdf58e83905b173e63d5ecf ]
commit 60792ad349f3c6dc5735aafefe5dc9121c79e320 upstream.
The pmuserenr_el0 register value is architecturally UNKNOWN on reset. Current kernel code resets that register value iff the core pmu device is correctly probed in the kernel. On platforms with missing DT pmu nodes (or disabled perf events in the kernel), the pmu is not probed, therefore the pmuserenr_el0 register is not reset in the kernel, which means that its value retains the reset value that is architecturally UNKNOWN (system may run with eg pmuserenr_el0 == 0x1, which means that PMU counters access is available at EL0, which must be disallowed).
This patch adds code that resets pmuserenr_el0 on cold boot and restores it on core resume from shutdown, so that the pmuserenr_el0 setup is always enforced in the kernel.
--- arch/arm64/kernel/perf_event.c | 3 --- arch/arm64/mm/proc.S | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-)
arch/arm64/kernel/perf_event.c +0 -3
@@ -1242,9 +1242,6 @@ static void armv8pmu_reset(void *info)/* Initialize & Reset PMNC: C and P bits. */ armv8pmu_pmcr_write (ARMV8_PMCR_P |ARMV8_PMCR_C ); - -/* Disable access from userspace. */ - asmvolatile ("msr pmuserenr_el0, %0" ::"r" (0 )); }static int armv8_pmuv3_map_event (struct perf_event *event)
arch/arm64/mm/proc.S +2 -0
@@ -165,6 +165,7 @@ ENTRY(cpu_do_resume) */ ubfx x11, x11, #1, #1 msr oslar_el1, x11 + msr pmuserenr_el0, xzr // Disable PMU access from EL0 mov x0, x12 dsb nsh // Make sure local tlb invalidation completed isb
@@ -204,6 +205,7 @@ ENTRY(__cpu_setup) msr cpacr_el1, x0 // Enable FP/ASIMD mov x0, #1 << 12 // Reset mdscr_el1 and disable msr mdscr_el1, x0 // access to the DCC from EL0 + msr pmuserenr_el0, xzr // Disable PMU access from EL0 /* * Memory region attributes for LPAE: *
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] nfs: Fix race in __update_open_stateid()
In reply to Sasha LevinFrom: Andrew Elble <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 361cad3c89070aeb37560860ea8bfc092d545adc ]
We've seen this in a packet capture - I've intermixed what I think was going on. The fix here is to grab the so_lock sooner.
1964379 -> #1 open (for write) reply seqid=1
1964393 -> #2 open (for read) reply seqid=2
__nfs4_close(), state->n_wronly-- nfs4_state_set_mode_locked(), changes state->state = [R] state->flags is [RW]
state->state is [R], state->n_wronly == 0, state->n_rdonly == 1
1964398 -> #3 open (for write) call -> because close is already running 1964399 -> downgrade (to read) call seqid=2 (close of #1) 1964402 -> #3 open (for write) reply seqid=3
__update_open_stateid()
nfs_set_open_stateid_locked(), changes state->flags state->flags is [RW]
state->state is [R], state->n_wronly == 0, state->n_rdonly == 1 new sequence number is exposed now via nfs4_stateid_copy()
next step would be update_open_stateflags(), pending so_lock
1964403 -> downgrade reply seqid=2, fails with OLD_STATEID (close of #1)
nfs4_close_prepare() gets so_lock and recalcs flags -> send close
1964405 -> downgrade (to read) call seqid=3 (close of #1 retry)
__update_open_stateid() gets so_lock
* update_open_stateflags() updates state->n_wronly. nfs4_state_set_mode_locked() updates state->state
state->flags is [RW]
state->state is [RW], state->n_wronly == 1, state->n_rdonly == 1
* should have suppressed the preceding nfs4_close_prepare() from sending open_downgrade
1964406 -> write call
1964408 -> downgrade (to read) reply seqid=4 (close of #1 retry)
nfs_clear_open_stateid_locked()
state->flags is [R]
state->state is [RW], state->n_wronly == 1, state->n_rdonly == 1
1964409 -> write reply (fails, openmode)
--- fs/nfs/nfs4proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4proc.c +1 -1
@@ -1284,6 +1284,7 @@ static void __update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_s* Protect the call to nfs4_state_set_mode_locked and * serialise the stateid update */ +spin_lock (&state->owner->so_lock);write_seqlock (&state->seqlock);if (deleg_stateid !=NULL ) {nfs4_stateid_copy (&state->stateid, deleg_stateid);
@@ -1292,7 +1293,6 @@ static void __update_open_stateid(struct nfs4_state *state, nfs4_stateid *open_sif (open_stateid !=NULL )nfs_set_open_stateid_locked (state, open_stateid, fmode);write_sequnlock (&state->seqlock); -spin_lock (&state->owner->so_lock);update_open_stateflags (state, fmode);spin_unlock (&state->owner->so_lock); }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] dm thin: fix race condition when destroying thin pool workqueue
In reply to Sasha LevinFrom: Nikolay Borisov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 18d03e8c25f173f4107a40d0b8c24defb6ed69f3 ]
When a thin pool is being destroyed delayed work items are cancelled using cancel_delayed_work(), which doesn't guarantee that on return the delayed item isn't running. This can cause the work item to requeue itself on an already destroyed workqueue. Fix this by using cancel_delayed_work_sync() which guarantees that on return the work item is not running anymore.
--- drivers/md/dm-thin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-thin.c +2 -2
@@ -3210,8 +3210,8 @@ static void pool_postsuspend(struct dm_target *ti)struct pool_c *pt = ti->private;struct pool *pool = pt->pool; -cancel_delayed_work (&pool->waker); -cancel_delayed_work (&pool->no_space_timeout); +cancel_delayed_work_sync (&pool->waker); +cancel_delayed_work_sync (&pool->no_space_timeout);flush_workqueue (pool->wq); (void )commit (pool); }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] Thermal: initialize thermal zone device correctly
In reply to Sasha LevinFrom: Zhang Rui <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bb431ba26c5cd0a17c941ca6c3a195a3a6d5d461 ]
After thermal zone device registered, as we have not read any temperature before, thus tz->temperature should not be 0, which actually means 0C, and thermal trend is not available. In this case, we need specially handling for the first thermal_zone_device_update().
Both thermal core framework and step_wise governor is enhanced to handle this. And since the step_wise governor is the only one that uses trends, so it's the only thermal governor that needs to be updated.
--- drivers/thermal/step_wise.c | 17 +++++++++++++++-- drivers/thermal/thermal_core.c | 19 +++++++++++++++++-- drivers/thermal/thermal_core.h | 1 + include/linux/thermal.h | 3 +++ 4 files changed, 36 insertions(+), 4 deletions(-)
drivers/thermal/step_wise.c +15 -2
@@ -63,6 +63,19 @@ static unsigned long get_target_state(struct thermal_instance *instance, next_target = instance->target;dev_dbg (&cdev->device,"cur_state=%ld\n" , cur_state); +if (!instance->initialized) { +if (throttle) { + next_target = (cur_state +1 ) >= instance->upper ? + instance->upper : + ((cur_state +1 ) < instance->lower ? + instance->lower : (cur_state +1 )); + }else { + next_target =THERMAL_NO_TARGET ; + } + +return next_target; + } +switch (trend) {case THERMAL_TREND_RAISING :if (throttle) {
@@ -149,7 +162,7 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)dev_dbg (&instance->cdev->device,"old_target=%d, target=%d\n" , old_target, (int )instance->target); -if (old_target == instance->target) +if (instance->initialized && old_target == instance->target)continue ;/* Activate a passive thermal instance */
@@ -161,7 +174,7 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) instance->target == THERMAL_NO_TARGET)update_passive_instance (tz, trip_type,-1 ); - + instance->initialized = true; instance->cdev->updated = false;/* cdev needs update */ }
drivers/thermal/thermal_core.c +17 -2
@@ -471,8 +471,22 @@ static void update_temperature(struct thermal_zone_device *tz)mutex_unlock (&tz->lock);trace_thermal_temperature (tz); -dev_dbg (&tz->device,"last_temperature=%d, current_temperature=%d\n" , - tz->last_temperature, tz->temperature); +if (tz->last_temperature ==THERMAL_TEMP_INVALID ) +dev_dbg (&tz->device,"last_temperature N/A, current_temperature=%d\n" , + tz->temperature); +else +dev_dbg (&tz->device,"last_temperature=%d, current_temperature=%d\n" , + tz->last_temperature, tz->temperature); +} + +static void thermal_zone_device_reset (struct thermal_zone_device *tz) +{ +struct thermal_instance *pos; + + tz->temperature =THERMAL_TEMP_INVALID ; + tz->passive =0 ; +list_for_each_entry (pos, &tz->thermal_instances, tz_node) + pos->initialized = false; }void thermal_zone_device_update (struct thermal_zone_device *tz)
@@ -1576,6 +1590,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,if (!tz->ops->get_temp)thermal_zone_device_set_polling (tz,0 ); +thermal_zone_device_reset (tz);thermal_zone_device_update (tz);return tz;
drivers/thermal/thermal_core.h +1 -0
@@ -41,6 +41,7 @@ struct thermal_instance {struct thermal_zone_device *tz;struct thermal_cooling_device *cdev;int trip; +bool initialized;unsigned long upper;/* Highest cooling state for this trip point */ unsigned long lower;/* Lowest cooling state for this trip point */ unsigned long target;/* expected cooling state */
include/linux/thermal.h +3 -0
@@ -40,6 +40,9 @@/* No upper/lower limit requirement */ #define THERMAL_NO_LIMIT ((u32)~0) +/* use value, which < 0K, to indicate an invalid/uninitialized temperature */ +#define THERMAL_TEMP_INVALID -274000 +/* Unit conversion macros */ #define KELVIN_TO_CELSIUS (t) (long)(((long)t-2732 >= 0) ? \ ((long)t-2732+5)/10 : ((long)t-2732-5)/10)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] Thermal: handle thermal zone device properly during system sleep
In reply to Sasha LevinFrom: Zhang Rui <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ff140fea847e1c2002a220571ab106c2456ed252 ]
Current thermal code does not handle system sleep well because
1. the cooling device cooling state may be changed during suspend
2. the previous temperature reading becomes invalid after resumed because it is got before system sleep
3. updating thermal zone device during suspending/resuming
is wrong because some devices may have already been suspended or may have not been resumed.
Thus, the proper way to do this is to cancel all thermal zone device update requirements during suspend/resume, and after all the devices have been resumed, reset and update every registered thermal zone devices.
This also fixes a regression introduced by:
Commit 19593a1fb1f6 ("ACPI / fan: convert to platform driver") Because, with above commit applied, all the fan devices are attached to the acpi_general_pm_domain, and they are turned on by the pm_domain automatically after resume, without the awareness of thermal core.
CC: <[email protected]> #3.18+
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=78201
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=91411
--- drivers/thermal/thermal_core.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
drivers/thermal/thermal_core.c +42 -0
@@ -37,6 +37,7 @@#include <linux/of.h> #include <net/netlink.h> #include <net/genetlink.h> +#include <linux/suspend.h> #define CREATE_TRACE_POINTS #include <trace/events/thermal.h>
@@ -59,6 +60,8 @@ static LIST_HEAD(thermal_governor_list);static DEFINE_MUTEX (thermal_list_lock);static DEFINE_MUTEX (thermal_governor_lock); +static atomic_t in_suspend; +static struct thermal_governor *def_governor;static struct thermal_governor *__find_governor (const char *name)
@@ -493,6 +496,9 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) {int count; +if (atomic_read (&in_suspend)) +return ; +if (!tz->ops->get_temp)return ;
@@ -1825,6 +1831,36 @@ static void thermal_unregister_governors(void)thermal_gov_user_space_unregister (); } +static int thermal_pm_notify (struct notifier_block *nb, +unsigned long mode,void *_unused) +{ +struct thermal_zone_device *tz; + +switch (mode) { +case PM_HIBERNATION_PREPARE : +case PM_RESTORE_PREPARE : +case PM_SUSPEND_PREPARE : +atomic_set (&in_suspend,1 ); +break ; +case PM_POST_HIBERNATION : +case PM_POST_RESTORE : +case PM_POST_SUSPEND : +atomic_set (&in_suspend,0 ); +list_for_each_entry (tz, &thermal_tz_list, node) { +thermal_zone_device_reset (tz); +thermal_zone_device_update (tz); + } +break ; +default : +break ; + } +return 0 ; +} + +static struct notifier_block thermal_pm_nb = { + .notifier_call = thermal_pm_notify, +}; +static int __init thermal_init (void ) {int result;
@@ -1845,6 +1881,11 @@ static int __init thermal_init(void)if (result) goto exit_netlink; + result =register_pm_notifier (&thermal_pm_nb); +if (result) +pr_warn ("Thermal: Can not register suspend notifier, return %d\n" , + result); +return 0 ; exit_netlink:
@@ -1864,6 +1905,7 @@ error: static void __exit thermal_exit(void) { +unregister_pm_notifier (&thermal_pm_nb);of_thermal_destroy_zones ();genetlink_exit ();class_unregister (&thermal_class);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] [media] rc: sunxi-cir: Initialize the spinlock properly
In reply to Sasha LevinFrom: Chen-Yu Tsai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 768acf46e1320d6c41ed1b7c4952bab41c1cde79 ]
The driver allocates the spinlock but fails to initialize it correctly. The kernel reports a BUG indicating bad spinlock magic when spinlock debugging is enabled.
Call spin_lock_init() on it to initialize it correctly.
--- drivers/media/rc/sunxi-cir.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/rc/sunxi-cir.c +2 -0
@@ -153,6 +153,8 @@ static int sunxi_ir_probe(struct platform_device *pdev)if (!ir)return -ENOMEM ; +spin_lock_init (&ir->ir_lock); +if (of_device_is_compatible (dn,"allwinner,sun5i-a13-ir" )) ir->fifo_size =64 ;else
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] Thermal: do thermal zone update after a cooling device registered
In reply to Sasha LevinFrom: Chen Yu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4511f7166a2deb5f7a578cf87fd2fe1ae83527e3 ]
When a new cooling device is registered, we need to update the thermal zone to set the new registered cooling device to a proper state.
This fixes a problem that the system is cool, while the fan devices are left running on full speed after boot, if fan device is registered after thermal zone device.
Here is the history of why current patch looks like this:
https://patchwork.kernel.org/patch/7273041/
CC: <[email protected]> #3.18+ Reference:https://bugzilla.kernel.org/show_bug.cgi?id=92431
--- drivers/thermal/thermal_core.c | 14 +++++++++++++- include/linux/thermal.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/thermal/thermal_core.c +13 -1
@@ -1036,6 +1036,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,if (!result) {list_add_tail (&dev->tz_node, &tz->thermal_instances);list_add_tail (&dev->cdev_node, &cdev->thermal_instances); +atomic_set (&tz->need_update,1 ); }mutex_unlock (&cdev->lock);mutex_unlock (&tz->lock);
@@ -1142,6 +1143,7 @@ __thermal_cooling_device_register(struct device_node *np, const struct thermal_cooling_device_ops *ops) {struct thermal_cooling_device *cdev; +struct thermal_zone_device *pos =NULL ;int result;if (type &&strlen (type) >=THERMAL_NAME_LENGTH )
@@ -1186,6 +1188,12 @@ __thermal_cooling_device_register(struct device_node *np,/* Update binding information for 'this' new cdev */ bind_cdev (cdev); +mutex_lock (&thermal_list_lock); +list_for_each_entry (pos, &thermal_tz_list, node) +if (atomic_cmpxchg (&pos->need_update,1 ,0 )) +thermal_zone_device_update (pos); +mutex_unlock (&thermal_list_lock); +return cdev; }
@@ -1516,6 +1524,8 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, tz->trips = trips; tz->passive_delay = passive_delay; tz->polling_delay = polling_delay; +/* A new thermal zone needs to be updated anyway. */ +atomic_set (&tz->need_update,1 );dev_set_name (&tz->device,"thermal_zone%d" , tz->id); result =device_register (&tz->device);
@@ -1597,7 +1607,9 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,thermal_zone_device_set_polling (tz,0 );thermal_zone_device_reset (tz); -thermal_zone_device_update (tz); +/* Update the new thermal zone and mark it as already updated. */ +if (atomic_cmpxchg (&tz->need_update,1 ,0 )) +thermal_zone_device_update (tz);return tz;
include/linux/thermal.h +2 -0
@@ -162,6 +162,7 @@ struct thermal_attr {* @forced_passive: If > 0, temperature at which to switch on all ACPI * processor cooling devices. Currently only used by the * step-wise governor. +* @need_update: if equals 1, thermal_zone_device_update needs to be invoked. * @ops: operations this &thermal_zone_device supports * @tzp: thermal zone parameters * @governor: pointer to the governor for this thermal zone
@@ -188,6 +189,7 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +atomic_t need_update;struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] udf: limit the maximum number of indirect extents in a row
In reply to Sasha LevinFrom: Vegard Nossum <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b0918d9f476a8434b055e362b83fa4fd1d462c3f ]
udf_next_aext() just follows extent pointers while extents are marked as indirect. This can loop forever for corrupted filesystem. Limit number the of indirect extents we are willing to follow in a row.
[JK: Updated changelog, limit, style]
--- fs/udf/inode.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/udf/inode.c +15 -0
@@ -2052,14 +2052,29 @@ void udf_write_aext(struct inode *inode, struct extent_position *epos, epos->offset += adsize; } +/* +* Only 1 indirect extent in a row really makes sense but allow upto 16 in case +* someone does some weird stuff. +*/ +#define UDF_MAX_INDIR_EXTS 16 +int8_t udf_next_aext (struct inode *inode,struct extent_position *epos,struct kernel_lb_addr *eloc,uint32_t *elen,int inc) {int8_t etype; +unsigned int indirections =0 ;while ((etype =udf_current_aext (inode, epos, eloc, elen, inc)) == (EXT_NEXT_EXTENT_ALLOCDECS >>30 )) {int block; + +if (++indirections >UDF_MAX_INDIR_EXTS ) { +udf_err (inode->i_sb, +"too many indirect extents in inode %lu\n" , + inode->i_ino); +return -1 ; + } + epos->block = *eloc; epos->offset =sizeof (struct allocExtDesc );brelse (epos->bh);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] NFS: Remove the "NFS_CAP_CHANGE_ATTR" capability
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cd812599796f500b042f5464b6665755eca21137 ]
Setting the change attribute has been mandatory for all NFS versions, since commit 3a1556e8662c ("NFSv2/v3: Simulate the change attribute"). We should therefore not have anything be conditional on it being set/unset.
--- fs/nfs/client.c | 2 +- fs/nfs/inode.c | 4 ++-- fs/nfs/nfs4proc.c | 3 --- include/linux/nfs_fs_sb.h | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-)
fs/nfs/client.c +1 -1
@@ -775,7 +775,7 @@ static int nfs_init_server(struct nfs_server *server, server->options = data->options; server->caps |=NFS_CAP_HARDLINKS |NFS_CAP_SYMLINKS |NFS_CAP_FILEID |NFS_CAP_MODE |NFS_CAP_NLINK |NFS_CAP_OWNER |NFS_CAP_OWNER_GROUP | -NFS_CAP_ATIME |NFS_CAP_CTIME |NFS_CAP_MTIME |NFS_CAP_CHANGE_ATTR ; +NFS_CAP_ATIME |NFS_CAP_CTIME |NFS_CAP_MTIME ;if (data->rsize) server->rsize =nfs_block_size (data->rsize,NULL );
fs/nfs/inode.c +2 -2
@@ -442,7 +442,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, stnfs_set_cache_invalid (inode,NFS_INO_INVALID_ATTR );if (fattr->valid &NFS_ATTR_FATTR_CHANGE ) inode->i_version = fattr->change_attr; -else if (nfs_server_capable (inode,NFS_CAP_CHANGE_ATTR )) +else nfs_set_cache_invalid (inode,NFS_INO_INVALID_ATTR );if (fattr->valid &NFS_ATTR_FATTR_SIZE ) inode->i_size =nfs_size_to_loff_t (fattr->size);
@@ -1688,7 +1688,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)nfs_force_lookup_revalidate (inode); inode->i_version = fattr->change_attr; } - }else if (server->caps &NFS_CAP_CHANGE_ATTR ) + }else nfsi->cache_validity |= save_cache_validity;if (fattr->valid &NFS_ATTR_FATTR_MTIME ) {
fs/nfs/nfs4proc.c +0 -3
@@ -8512,7 +8512,6 @@ static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = { .minor_version = 0, .init_caps =NFS_CAP_READDIRPLUS |NFS_CAP_ATOMIC_OPEN - |NFS_CAP_CHANGE_ATTR | NFS_CAP_POSIX_LOCK, .init_client = nfs40_init_client, .shutdown_client = nfs40_shutdown_client,
@@ -8538,7 +8537,6 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = { .minor_version = 1, .init_caps =NFS_CAP_READDIRPLUS |NFS_CAP_ATOMIC_OPEN - |NFS_CAP_CHANGE_ATTR |NFS_CAP_POSIX_LOCK |NFS_CAP_STATEID_NFSV41 | NFS_CAP_ATOMIC_OPEN_V1,
@@ -8561,7 +8559,6 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = { .minor_version = 2, .init_caps =NFS_CAP_READDIRPLUS |NFS_CAP_ATOMIC_OPEN - |NFS_CAP_CHANGE_ATTR |NFS_CAP_POSIX_LOCK |NFS_CAP_STATEID_NFSV41 |NFS_CAP_ATOMIC_OPEN_V1
include/linux/nfs_fs_sb.h +1 -1
@@ -220,7 +220,7 @@ struct nfs_server {#define NFS_CAP_SYMLINKS (1U << 2)#define NFS_CAP_ACLS (1U << 3)#define NFS_CAP_ATOMIC_OPEN (1U << 4) -#define NFS_CAP_CHANGE_ATTR (1U << 5) +/* #define NFS_CAP_CHANGE_ATTR (1U << 5) */ #define NFS_CAP_FILEID (1U << 6)#define NFS_CAP_MODE (1U << 7)#define NFS_CAP_NLINK (1U << 8)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] NFS: Fix attribute cache revalidation
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ade14a7df796d4e86bd9d181193c883a57b13db0 ]
If a NFSv4 client uses the cache_consistency_bitmask in order to request only information about the change attribute, timestamps and size, then it has not revalidated all attributes, and hence the attribute timeout timestamp should not be updated.
--- fs/nfs/inode.c | 54 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 15 deletions(-)
fs/nfs/inode.c +39 -15
@@ -1627,6 +1627,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)unsigned long invalid =0 ;unsigned long now = jiffies;unsigned long save_cache_validity; +bool cache_revalidated = true; dfprintk(VFS, "NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%x)\n", __func__, inode->i_sb->s_id, inode->i_ino,
@@ -1688,22 +1689,28 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)nfs_force_lookup_revalidate (inode); inode->i_version = fattr->change_attr; } - }else + }else { nfsi->cache_validity |= save_cache_validity; + cache_revalidated = false; + }if (fattr->valid &NFS_ATTR_FATTR_MTIME ) {memcpy (&inode->i_mtime, &fattr->mtime,sizeof (inode->i_mtime)); - }else if (server->caps &NFS_CAP_MTIME ) + }else if (server->caps &NFS_CAP_MTIME ) { nfsi->cache_validity |= save_cache_validity & (NFS_INO_INVALID_ATTR |NFS_INO_REVAL_FORCED ); + cache_revalidated = false; + }if (fattr->valid &NFS_ATTR_FATTR_CTIME ) {memcpy (&inode->i_ctime, &fattr->ctime,sizeof (inode->i_ctime)); - }else if (server->caps &NFS_CAP_CTIME ) + }else if (server->caps &NFS_CAP_CTIME ) { nfsi->cache_validity |= save_cache_validity & (NFS_INO_INVALID_ATTR |NFS_INO_REVAL_FORCED ); + cache_revalidated = false; + }/* Check if our cached file size is stale */ if (fattr->valid &NFS_ATTR_FATTR_SIZE ) {
@@ -1723,19 +1730,23 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) (long long )cur_isize, (long long)new_isize); } - }else + }else { nfsi->cache_validity |= save_cache_validity & (NFS_INO_INVALID_ATTR |NFS_INO_REVAL_PAGECACHE |NFS_INO_REVAL_FORCED ); + cache_revalidated = false; + }if (fattr->valid &NFS_ATTR_FATTR_ATIME )memcpy (&inode->i_atime, &fattr->atime,sizeof (inode->i_atime)); -else if (server->caps &NFS_CAP_ATIME ) +else if (server->caps &NFS_CAP_ATIME ) { nfsi->cache_validity |= save_cache_validity & (NFS_INO_INVALID_ATIME |NFS_INO_REVAL_FORCED ); + cache_revalidated = false; + }if (fattr->valid &NFS_ATTR_FATTR_MODE ) {if ((inode->i_mode &S_IALLUGO ) != (fattr->mode &S_IALLUGO )) {
@@ -1744,36 +1755,42 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) inode->i_mode = newmode; invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; } - }else if (server->caps &NFS_CAP_MODE ) + }else if (server->caps &NFS_CAP_MODE ) { nfsi->cache_validity |= save_cache_validity & (NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL |NFS_INO_REVAL_FORCED ); + cache_revalidated = false; + }if (fattr->valid &NFS_ATTR_FATTR_OWNER ) {if (!uid_eq (inode->i_uid, fattr->uid)) { invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; inode->i_uid = fattr->uid; } - }else if (server->caps &NFS_CAP_OWNER ) + }else if (server->caps &NFS_CAP_OWNER ) { nfsi->cache_validity |= save_cache_validity & (NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL |NFS_INO_REVAL_FORCED ); + cache_revalidated = false; + }if (fattr->valid &NFS_ATTR_FATTR_GROUP ) {if (!gid_eq (inode->i_gid, fattr->gid)) { invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL ; inode->i_gid = fattr->gid; } - }else if (server->caps &NFS_CAP_OWNER_GROUP ) + }else if (server->caps &NFS_CAP_OWNER_GROUP ) { nfsi->cache_validity |= save_cache_validity & (NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS |NFS_INO_INVALID_ACL |NFS_INO_REVAL_FORCED ); + cache_revalidated = false; + }if (fattr->valid &NFS_ATTR_FATTR_NLINK ) {if (inode->i_nlink != fattr->nlink) {
@@ -1782,19 +1799,22 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) invalid |=NFS_INO_INVALID_DATA ;set_nlink (inode, fattr->nlink); } - }else if (server->caps &NFS_CAP_NLINK ) + }else if (server->caps &NFS_CAP_NLINK ) { nfsi->cache_validity |= save_cache_validity & (NFS_INO_INVALID_ATTR |NFS_INO_REVAL_FORCED ); + cache_revalidated = false; + }if (fattr->valid &NFS_ATTR_FATTR_SPACE_USED ) {/* * report the blocks in 512byte units */ inode->i_blocks =nfs_calc_block_size (fattr->du.nfs3.used); - } -if (fattr->valid &NFS_ATTR_FATTR_BLOCKS_USED ) + }else if (fattr->valid &NFS_ATTR_FATTR_BLOCKS_USED ) inode->i_blocks = fattr->du.nfs2.blocks; +else + cache_revalidated = false;/* Update attrtimeo value if we're out of the unstable period */ if (invalid &NFS_INO_INVALID_ATTR ) {
@@ -1804,9 +1824,13 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)/* Set barrier to be more recent than all outstanding updates */ nfsi->attr_gencount =nfs_inc_attr_generation_counter (); }else { -if (!time_in_range_open (now, nfsi->attrtimeo_timestamp, nfsi->attrtimeo_timestamp + nfsi->attrtimeo)) { -if ((nfsi->attrtimeo <<=1 ) >NFS_MAXATTRTIMEO (inode)) - nfsi->attrtimeo =NFS_MAXATTRTIMEO (inode); +if (cache_revalidated) { +if (!time_in_range_open (now, nfsi->attrtimeo_timestamp, + nfsi->attrtimeo_timestamp + nfsi->attrtimeo)) { + nfsi->attrtimeo <<=1 ; +if (nfsi->attrtimeo >NFS_MAXATTRTIMEO (inode)) + nfsi->attrtimeo =NFS_MAXATTRTIMEO (inode); + } nfsi->attrtimeo_timestamp = now; }/* Set the barrier to be more recent than this fattr */
@@ -1815,7 +1839,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) }/* Don't declare attrcache up to date if there were no attrs! */ -if (fattr->valid !=0 ) +if (cache_revalidated) invalid &= ~NFS_INO_INVALID_ATTR ;/* Don't invalidate the data if we were to blame */
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] rtlwifi: rtl8188ee: Fix module parameter initialization
In reply to Sasha LevinFrom: Larry Finger <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 06f34572c6110e2e2d5e653a957f1d74db9e3f2b ]
In this driver, parameters disable_watchdog and sw_crypto are never copied into the locations used in the main code. While modifying the parameter handling, the copying of parameter msi_support is moved to be with the rest.
--- drivers/net/wireless/rtlwifi/rtl8188ee/sw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/rtlwifi/rtl8188ee/sw.c +5 -2
@@ -88,8 +88,6 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw)u8 tid;rtl8188ee_bt_reg_init (hw); - rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; - rtlpriv->dm.dm_initialgain_enable =1 ; rtlpriv->dm.dm_flag =0 ; rtlpriv->dm.disable_framebursting =0 ;
@@ -138,6 +136,11 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->psc.inactiveps = rtlpriv->cfg->mod_params->inactiveps; rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; + rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; + rtlpriv->cfg->mod_params->sw_crypto = + rtlpriv->cfg->mod_params->sw_crypto; + rtlpriv->cfg->mod_params->disable_watchdog = + rtlpriv->cfg->mod_params->disable_watchdog;if (rtlpriv->cfg->mod_params->disable_watchdog)pr_info ("watchdog disabled\n" );if (!rtlpriv->psc.inactiveps)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] rtlwifi: rtl8192se: Fix module parameter initialization
In reply to Sasha LevinFrom: Larry Finger <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7503efbd82c15c4070adffff1344e5169d3634b4 ]
Two of the module parameter descriptions show incorrect default values. In addition the value for software encryption is not transferred to the locations used by the driver.
--- drivers/net/wireless/rtlwifi/rtl8192se/sw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/rtlwifi/rtl8192se/sw.c +4 -2
@@ -187,6 +187,8 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->psc.inactiveps = rtlpriv->cfg->mod_params->inactiveps; rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; + rtlpriv->cfg->mod_params->sw_crypto = + rtlpriv->cfg->mod_params->sw_crypto;if (!rtlpriv->psc.inactiveps)pr_info ("Power Save off (module option)\n" );if (!rtlpriv->psc.fwctrl_lps)
@@ -425,8 +427,8 @@ module_param_named(swlps, rtl92se_mod_params.swctrl_lps, bool, 0444);module_param_named (fwlps, rtl92se_mod_params.fwctrl_lps, bool,0444 );MODULE_PARM_DESC (swenc,"Set to 1 for software crypto (default 0)\n" );MODULE_PARM_DESC (ips,"Set to 0 to not use link power save (default 1)\n" ); -MODULE_PARM_DESC (swlps,"Set to 1 to use SW control power save (default 0)\n" ); -MODULE_PARM_DESC (fwlps,"Set to 1 to use FW control power save (default 1)\n" ); +MODULE_PARM_DESC (swlps,"Set to 1 to use SW control power save (default 1)\n" ); +MODULE_PARM_DESC (fwlps,"Set to 1 to use FW control power save (default 0)\n" );MODULE_PARM_DESC (debug,"Set debug level (0-5) (default 0)" ); static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] rtlwifi: rtl8192cu: Add missing parameter setup
In reply to Sasha LevinFrom: Larry Finger <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b68d0ae7e58624c33f2eddab471fee55db27dbf9 ]
This driver fails to copy the module parameter for software encryption to the locations used by the main code.
--- drivers/net/wireless/rtlwifi/rtl8192cu/sw.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +2 -0
@@ -65,6 +65,8 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->dm.disable_framebursting = false; rtlpriv->dm.thermalvalue =0 ; rtlpriv->dbg.global_debuglevel = rtlpriv->cfg->mod_params->debug; + rtlpriv->cfg->mod_params->sw_crypto = + rtlpriv->cfg->mod_params->sw_crypto;/* for firmware buf */ rtlpriv->rtlhal.pfirmware =vzalloc (0x4000 );
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] rtlwifi: rtl8192ce: Fix handling of module parameters
In reply to Sasha LevinFrom: Larry Finger <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b24f19f16b9e43f54218c07609b783ea8625406a ]
The module parameter for software encryption was never transferred to the location used by the driver.
--- drivers/net/wireless/rtlwifi/rtl8192ce/sw.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/rtlwifi/rtl8192ce/sw.c +2 -0
@@ -139,6 +139,8 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw) rtlpriv->psc.inactiveps = rtlpriv->cfg->mod_params->inactiveps; rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; + rtlpriv->cfg->mod_params->sw_crypto = + rtlpriv->cfg->mod_params->sw_crypto;if (!rtlpriv->psc.inactiveps)pr_info ("rtl8192ce: Power Save off (module option)\n" );if (!rtlpriv->psc.fwctrl_lps)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] rtlwifi: rtl_pci: Fix kernel panic
In reply to Sasha LevinFrom: Larry Finger <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f99551a2d39dc26ea03dc6761be11ac913eb2d57 ]
In commit 38506ecefab9 (rtlwifi: rtl_pci: Start modification for new drivers), a bug was introduced that causes a NULL pointer dereference. As this bug only affects the infrequently used RTL8192EE and only under low-memory conditions, it has taken a long time for the bug to show up.
The bug was reported on the linux-wireless mailing list and also at
https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/ as bug #1527603 (kernel crashes due to rtl8192ee driver on ubuntu 15.10).
--- drivers/net/wireless/rtlwifi/pci.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/net/wireless/rtlwifi/pci.c +3 -8
@@ -801,7 +801,9 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) hw_queue);if (rx_remained_cnt ==0 )return ; - + buffer_desc = &rtlpci->rx_ring[rxring_idx].buffer_desc[ + rtlpci->rx_ring[rxring_idx].idx]; + pdesc = (struct rtl_rx_desc *)skb->data; }else {/* rx descriptor */ pdesc = &rtlpci->rx_ring[rxring_idx].desc[ rtlpci->rx_ring[rxring_idx].idx];
@@ -824,13 +826,6 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) new_skb =dev_alloc_skb (rtlpci->rxbuffersize);if (unlikely (!new_skb)) goto no_new; -if (rtlpriv->use_new_trx_flow) { - buffer_desc = - &rtlpci->rx_ring[rxring_idx].buffer_desc - [rtlpci->rx_ring[rxring_idx].idx]; -/*means rx wifi info*/ - pdesc = (struct rtl_rx_desc *)skb->data; - }memset (&rx_status ,0 ,sizeof (rx_status)); rtlpriv->cfg->ops->query_rx_desc (hw, &stats, &rx_status, (u8 *)pdesc, skb);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] bcache: fix a leak in bch_cached_dev_run()
In reply to Sasha LevinFrom: Al Viro <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4d4d8573a8451acc9f01cbea24b7e55f04a252fe ]
--- drivers/md/bcache/super.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/bcache/super.c +4 -1
@@ -880,8 +880,11 @@ void bch_cached_dev_run(struct cached_dev *dc) buf[SB_LABEL_SIZE ] ='\0' ; env[2 ] =kasprintf (GFP_KERNEL ,"CACHED_LABEL=%s" , buf); -if (atomic_xchg (&dc->running,1 )) +if (atomic_xchg (&dc->running,1 )) { +kfree (env[1 ]); +kfree (env[2 ]);return ; + }if (!d->c &&BDEV_STATE (&dc->sb) !=BDEV_STATE_NONE ) {
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] bcache: Add a cond_resched() call to gc
In reply to Sasha LevinFrom: Kent Overstreet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c5f1e5adf956e3ba82d204c7c141a75da9fa449a ]
--- drivers/md/bcache/btree.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/bcache/btree.c +1 -0
@@ -1741,6 +1741,7 @@ static void bch_btree_gc(struct cache_set *c) do { ret = btree_root(gc_root, c, &op, &writes, &stats); closure_sync(&writes); + cond_resched(); if (ret && ret != -EAGAIN) pr_warn("gc failed!");
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] bcache: clear BCACHE_DEV_UNLINK_DONE flag when attaching a backing device
In reply to Sasha LevinFrom: Zheng Liu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fecaee6f20ee122ad75402c53d8278f9bb142ddc ]
This bug can be reproduced by the following script:
#!/bin/bash
bcache_sysfs="/sys/fs/bcache"
function clear_cache()
{
if [ ! -e $bcache_sysfs ]; then
echo "no bcache sysfs"
exit
fi
cset_uuid=$(ls -l $bcache_sysfs|head -n 2|tail -n 1|awk '{print $9}')
sudo sh -c "echo $cset_uuid > /sys/block/sdb/sdb1/bcache/detach"
sleep 5
sudo sh -c "echo $cset_uuid > /sys/block/sdb/sdb1/bcache/attach"
} for ((i=0;i<10;i++)); do
clear_cache
done
The warning messages look like below:
[ 275.948611] ------------[ cut here ]------------ [ 275.963840] WARNING: at fs/sysfs/dir.c:512 sysfs_add_one+0xb8/0xd0() (Tainted: P W --------------- ) [ 275.979253] Hardware name: Tecal RH2285 [ 275.994106] sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:09.0/0000:08:00.0/host4/target4:2:1/4:2:1:0/block/sdb/sdb1/bcache/cache' [ 276.024105] Modules linked in: bcache tcp_diag inet_diag ipmi_devintf ipmi_si ipmi_msghandler bonding 8021q garp stp llc ipv6 ext3 jbd loop sg iomemory_vsl(P) bnx2 microcode serio_raw i2c_i801 i2c_core iTCO_wdt iTCO_vendor_support i7core_edac edac_core shpchp ext4 jbd2 mbcache megaraid_sas pata_acpi ata_generic ata_piix dm_mod [last unloaded: scsi_wait_scan] [ 276.072643] Pid: 2765, comm: sh Tainted: P W --------------- 2.6.32 #1 [ 276.089315] Call Trace: [ 276.105801] [<ffffffff81070fe7>] ? warn_slowpath_common+0x87/0xc0 [ 276.122650] [<ffffffff810710d6>] ? warn_slowpath_fmt+0x46/0x50 [ 276.139361] [<ffffffff81205c08>] ? sysfs_add_one+0xb8/0xd0 [ 276.156012] [<ffffffff8120609b>] ? sysfs_do_create_link+0x12b/0x170 [ 276.172682] [<ffffffff81206113>] ? sysfs_create_link+0x13/0x20 [ 276.189282] [<ffffffffa03bda21>] ? bcache_device_link+0xc1/0x110 [bcache] [ 276.205993] [<ffffffffa03bfa08>] ? bch_cached_dev_attach+0x478/0x4f0 [bcache] [ 276.222794] [<ffffffffa03c4a17>] ? bch_cached_dev_store+0x627/0x780 [bcache] [ 276.239680] [<ffffffff8116783a>] ? alloc_pages_current+0xaa/0x110 [ 276.256594] [<ffffffff81203b15>] ? sysfs_write_file+0xe5/0x170 [ 276.273364] [<ffffffff811887b8>] ? vfs_write+0xb8/0x1a0 [ 276.290133] [<ffffffff811890b1>] ? sys_write+0x51/0x90 [ 276.306368] [<ffffffff8100c072>] ? system_call_fastpath+0x16/0x1b [ 276.322301] ---[ end trace 9f5d4fcdd0c3edfb ]--- [ 276.338241] ------------[ cut here ]------------ [ 276.354109] WARNING: at /home/wenqing.lz/bcache/bcache/super.c:720 bcache_device_link+0xdf/0x110 [bcache]() (Tainted: P W --------------- ) [ 276.386017] Hardware name: Tecal RH2285 [ 276.401430] Couldn't create device <-> cache set symlinks [ 276.401759] Modules linked in: bcache tcp_diag inet_diag ipmi_devintf ipmi_si ipmi_msghandler bonding 8021q garp stp llc ipv6 ext3 jbd loop sg iomemory_vsl(P) bnx2 microcode serio_raw i2c_i801 i2c_core iTCO_wdt iTCO_vendor_support i7core_edac edac_core shpchp ext4 jbd2 mbcache megaraid_sas pata_acpi ata_generic ata_piix dm_mod [last unloaded: scsi_wait_scan] [ 276.465477] Pid: 2765, comm: sh Tainted: P W --------------- 2.6.32 #1 [ 276.482169] Call Trace: [ 276.498610] [<ffffffff81070fe7>] ? warn_slowpath_common+0x87/0xc0 [ 276.515405] [<ffffffff810710d6>] ? warn_slowpath_fmt+0x46/0x50 [ 276.532059] [<ffffffffa03bda3f>] ? bcache_device_link+0xdf/0x110 [bcache] [ 276.548808] [<ffffffffa03bfa08>] ? bch_cached_dev_attach+0x478/0x4f0 [bcache] [ 276.565569] [<ffffffffa03c4a17>] ? bch_cached_dev_store+0x627/0x780 [bcache] [ 276.582418] [<ffffffff8116783a>] ? alloc_pages_current+0xaa/0x110 [ 276.599341] [<ffffffff81203b15>] ? sysfs_write_file+0xe5/0x170 [ 276.616142] [<ffffffff811887b8>] ? vfs_write+0xb8/0x1a0 [ 276.632607] [<ffffffff811890b1>] ? sys_write+0x51/0x90 [ 276.648671] [<ffffffff8100c072>] ? system_call_fastpath+0x16/0x1b [ 276.664756] ---[ end trace 9f5d4fcdd0c3edfc ]---
We forget to clear BCACHE_DEV_UNLINK_DONE flag in bcache_device_attach() function when we attach a backing device first time. After detaching this backing device, this flag will be true and sysfs_remove_link() isn't called in bcache_device_unlink(). Then when we attach this backing device again, sysfs_create_link() will return EEXIST error in bcache_device_link().
So the fix is trival and we clear this flag in bcache_device_link().
--- drivers/md/bcache/super.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/bcache/super.c +2 -0
@@ -708,6 +708,8 @@ static void bcache_device_link(struct bcache_device *d, struct cache_set *c,WARN (sysfs_create_link (&d->kobj, &c->kobj,"cache" ) ||sysfs_create_link (&c->kobj, &d->kobj, d->name),"Couldn't create device <-> cache set symlinks" ); + +clear_bit (BCACHE_DEV_UNLINK_DONE , &d->flags); }static void bcache_device_detach (struct bcache_device *d)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] bcache: fix a livelock when we cause a huge number of cache misses
In reply to Sasha LevinFrom: Zheng Liu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 2ef9ccbfcb90cf84bdba320a571b18b05c41101b ]
Subject : [PATCH v2] bcache: fix a livelock in btree lock
Date : Wed, 25 Feb 2015 20:32:09 +0800 (02/25/2015 04:32:09 AM)
This commit tries to fix a livelock in bcache. This livelock might happen when we causes a huge number of cache misses simultaneously.
When we get a cache miss, bcache will execute the following path.
->cached_dev_make_request()
->cached_dev_read()
->cached_lookup()
->bch->btree_map_keys()
->btree_root() <------------------------
->bch_btree_map_keys_recurse() |
->cache_lookup_fn() |
->cached_dev_cache_miss() |
->bch_btree_insert_check_key() -|
[If btree->seq is not equal to seq + 1, we should return
EINTR and traverse btree again.]In bch_btree_insert_check_key() function we first need to check upgrade flag (op->lock == -1), and when this flag is true we need to release read btree->lock and try to take write btree->lock. During taking and releasing this write lock, btree->seq will be monotone increased in order to prevent other threads modify this in cache miss (see btree.h:74). But if there are some cache misses caused by some requested, we could meet a livelock because btree->seq is always changed by others. Thus no one can make progress.
This commit will try to take write btree->lock if it encounters a race when we traverse btree. Although it sacrifice the scalability but we can ensure that only one can modify the btree.
--- drivers/md/bcache/btree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +3 -1
@@ -2162,8 +2162,10 @@ int bch_btree_insert_check_key(struct btree *b, struct btree_op *op,rw_lock (true, b, b->level);if (b->key.ptr[0 ] != btree_ptr || - b->seq != seq +1 ) + b->seq != seq +1 ) { + op->lock = b->level; goto out; + } }SET_KEY_PTRS (check_key,1 );
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] bcache: Change refill_dirty() to always scan entire disk if necessary
In reply to Sasha LevinFrom: Kent Overstreet <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 627ccd20b4ad3ba836472468208e2ac4dfadbf03 ]
Previously, it would only scan the entire disk if it was starting from the very start of the disk - i.e. if the previous scan got to the end.
This was broken by refill_full_stripes(), which updates last_scanned so that refill_dirty was never triggering the searched_from_start path.
But if we change refill_dirty() to always scan the entire disk if necessary, regardless of what last_scanned was, the code gets cleaner and we fix that bug too.
--- drivers/md/bcache/writeback.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-)
drivers/md/bcache/writeback.c +30 -7
@@ -323,6 +323,10 @@ void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned inode,static bool dirty_pred (struct keybuf *buf,struct bkey *k) { + struct cached_dev *dc = container_of(buf, struct cached_dev, writeback_keys); + +BUG_ON (KEY_INODE (k) != dc->disk.id); +return KEY_DIRTY (k); }
@@ -372,11 +376,24 @@ next: } } +/* +* Returns true if we scanned the entire disk +*/ static bool refill_dirty (struct cached_dev *dc) {struct keybuf *buf = &dc->writeback_keys; +struct bkey start =KEY (dc->disk.id,0 ,0 );struct bkey end =KEY (dc->disk.id,MAX_KEY_OFFSET ,0 ); -bool searched_from_start = false; +struct bkey start_pos; + +/* +* make sure keybuf pos is inside the range for this disk - at bringup +* we might not be attached yet so this disk's inode nr isn't +* initialized then +*/ +if (bkey_cmp (&buf->last_scanned, &start) <0 || +bkey_cmp (&buf->last_scanned, &end) >0 ) + buf->last_scanned = start;if (dc->partial_stripes_expensive) {refill_full_stripes (dc);
@@ -384,14 +401,20 @@ static bool refill_dirty(struct cached_dev *dc)return false; } -if (bkey_cmp (&buf->last_scanned, &end) >=0 ) { - buf->last_scanned =KEY (dc->disk.id,0 ,0 ); - searched_from_start = true; - } - + start_pos = buf->last_scanned;bch_refill_keybuf (dc->disk.c, buf, &end, dirty_pred); -return bkey_cmp (&buf->last_scanned, &end) >=0 && searched_from_start; +if (bkey_cmp (&buf->last_scanned, &end) <0 ) +return false; + +/* +* If we get to the end start scanning again from the beginning, and +* only scan up to where we initially started scanning from: +*/ + buf->last_scanned = start; +bch_refill_keybuf (dc->disk.c, buf, &start_pos, dirty_pred); + +return bkey_cmp (&buf->last_scanned, &start_pos) >=0 ; }static int bch_writeback_thread (void *arg)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] bcache: unregister reboot notifier if bcache fails to unregister device
In reply to Sasha LevinFrom: Zheng Liu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 2ecf0cdb2b437402110ab57546e02abfa68a716b ]
In bcache_init() function it forgot to unregister reboot notifier if bcache fails to unregister a block device. This commit fixes this.
--- drivers/md/bcache/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/bcache/super.c +3 -1
@@ -2105,8 +2105,10 @@ static int __init bcache_init(void)closure_debug_init (); bcache_major =register_blkdev (0 ,"bcache" ); -if (bcache_major <0 ) +if (bcache_major <0 ) { +unregister_reboot_notifier (&reboot);return bcache_major; + } if (!(bcache_wq = create_workqueue("bcache")) || !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) ||
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] bcache: prevent crash on changing writeback_running
In reply to Sasha LevinFrom: Stefan Bader <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8d16ce540c94c9d366eb36fc91b7154d92d6397b ]
Added a safeguard in the shutdown case. At least while not being attached it is also possible to trigger a kernel bug by writing into writeback_running. This change adds the same check before trying to wake up the thread for that case.
--- drivers/md/bcache/writeback.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/bcache/writeback.h +2 -1
@@ -63,7 +63,8 @@ static inline bool should_writeback(struct cached_dev *dc, struct bio *bio,static inline void bch_writeback_queue (struct cached_dev *dc) { -wake_up_process (dc->writeback_thread); +if (!IS_ERR_OR_NULL (dc->writeback_thread)) +wake_up_process (dc->writeback_thread); }static inline void bch_writeback_add (struct cached_dev *dc)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] Input: i8042 - add Fujitsu Lifebook U745 to the nomux list
In reply to Sasha LevinFrom: Aurélien Francillon <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit dd0d0d4de582a6a61c032332c91f4f4cb2bab569 ]
Without i8042.nomux=1 the Elantech touch pad is not working at all on a Fujitsu Lifebook U745. This patch does not seem necessary for all U745 (maybe because of different BIOS versions?). However, it was verified that the patch does not break those (see opensuse bug 883192:
https://bugzilla.opensuse.org/show_bug.cgi?id=883192).
--- drivers/input/serio/i8042-x86ia64io.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +7 -0
@@ -258,6 +258,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = { }, }, { +/* Fujitsu Lifebook U745 */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"FUJITSU" ), + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U745"), + }, + }, + {/* Fujitsu T70H */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] drm/dp/mst: process broadcast messages correctly
In reply to Sasha LevinFrom: Mykola Lysenko <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bd9343208704fcc70a5b919f228a7d26ae472727 ]
In case broadcast message received in UP request, RAD cannot be used to identify message originator. Message should be parsed, originator should be found by GUID from parsed message.
Also reply with broadcast in case broadcast message received (for now it is always broadcast)
--- drivers/gpu/drm/drm_dp_mst_topology.c | 95 +++++++++++++++++++++++++++++++---- 1 file changed, 84 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c +84 -11
@@ -1195,6 +1195,50 @@ out:return mstb; } +static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper ( +struct drm_dp_mst_branch *mstb, +uint8_t *guid) +{ +struct drm_dp_mst_branch *found_mstb; +struct drm_dp_mst_port *port; + +list_for_each_entry (port, &mstb->ports, next) { +if (!port->mstb) +continue ; + +if (port->guid_valid &&memcmp (port->guid, guid,16 ) ==0 ) +return port->mstb; + + found_mstb =get_mst_branch_device_by_guid_helper (port->mstb, guid); + +if (found_mstb) +return found_mstb; + } + +return NULL ; +} + +static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device_by_guid ( +struct drm_dp_mst_topology_mgr *mgr, +uint8_t *guid) +{ +struct drm_dp_mst_branch *mstb; + +/* find the port by iterating down */ +mutex_lock (&mgr->lock); + +if (mgr->guid_valid &&memcmp (mgr->guid, guid,16 ) ==0 ) + mstb = mgr->mst_primary; +else + mstb =get_mst_branch_device_by_guid_helper (mgr->mst_primary, guid); + +if (mstb) +kref_get (&mstb->kref); + +mutex_unlock (&mgr->lock); +return mstb; +} +static void drm_dp_check_and_send_link_address (struct drm_dp_mst_topology_mgr *mgr,struct drm_dp_mst_branch *mstb) {
@@ -1306,6 +1350,7 @@ static int set_hdr_from_dst_qlock(struct drm_dp_sideband_msg_hdr *hdr, struct drm_dp_sideband_msg_tx *txmsg) {struct drm_dp_mst_branch *mstb = txmsg->dst; +u8 req_type;/* both msg slots are full */ if (txmsg->seqno ==-1 ) {
@@ -1322,7 +1367,13 @@ static int set_hdr_from_dst_qlock(struct drm_dp_sideband_msg_hdr *hdr, txmsg->seqno =1 ; mstb->tx_slots[txmsg->seqno] = txmsg; } - hdr->broadcast =0 ; + + req_type = txmsg->msg[0 ] &0x7f ; +if (req_type ==DP_CONNECTION_STATUS_NOTIFY || + req_type ==DP_RESOURCE_STATUS_NOTIFY ) + hdr->broadcast =1 ; +else + hdr->broadcast =0 ; hdr->path_msg = txmsg->path_msg; hdr->lct = mstb->lct; hdr->lcr = mstb->lct -1 ;
@@ -2129,28 +2180,50 @@ static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr)if (mgr->up_req_recv.have_eomt) {struct drm_dp_sideband_msg_req_body msg; -struct drm_dp_mst_branch *mstb; +struct drm_dp_mst_branch *mstb =NULL ;bool seqno; - mstb =drm_dp_get_mst_branch_device (mgr, - mgr->up_req_recv.initial_hdr.lct, - mgr->up_req_recv.initial_hdr.rad); -if (!mstb) { -DRM_DEBUG_KMS ("Got MST reply from unknown device %d\n" , mgr->up_req_recv.initial_hdr.lct); -memset (&mgr->up_req_recv,0 ,sizeof (struct drm_dp_sideband_msg_rx )); -return 0 ; + +if (!mgr->up_req_recv.initial_hdr.broadcast) { + mstb =drm_dp_get_mst_branch_device (mgr, + mgr->up_req_recv.initial_hdr.lct, + mgr->up_req_recv.initial_hdr.rad); +if (!mstb) { +DRM_DEBUG_KMS ("Got MST reply from unknown device %d\n" , mgr->up_req_recv.initial_hdr.lct); +memset (&mgr->up_req_recv,0 ,sizeof (struct drm_dp_sideband_msg_rx )); +return 0 ; + } } seqno = mgr->up_req_recv.initial_hdr.seqno;drm_dp_sideband_parse_req (&mgr->up_req_recv, &msg);if (msg.req_type ==DP_CONNECTION_STATUS_NOTIFY ) { -drm_dp_send_up_ack_reply (mgr, mstb, msg.req_type, seqno, false); +drm_dp_send_up_ack_reply (mgr, mgr->mst_primary, msg.req_type, seqno, false); + +if (!mstb) + mstb =drm_dp_get_mst_branch_device_by_guid (mgr, msg.u.conn_stat.guid); + +if (!mstb) { +DRM_DEBUG_KMS ("Got MST reply from unknown device %d\n" , mgr->up_req_recv.initial_hdr.lct); +memset (&mgr->up_req_recv,0 ,sizeof (struct drm_dp_sideband_msg_rx )); +return 0 ; + } +drm_dp_update_port (mstb, &msg.u.conn_stat);DRM_DEBUG_KMS ("Got CSN: pn: %d ldps:%d ddps: %d mcs: %d ip: %d pdt: %d\n" , msg.u.conn_stat.port_number, msg.u.conn_stat.legacy_device_plug_status, msg.u.conn_stat.displayport_device_plug_status, msg.u.conn_stat.message_capability_status, msg.u.conn_stat.input_port, msg.u.conn_stat.peer_device_type); (*mgr->cbs->hotplug)(mgr); }else if (msg.req_type ==DP_RESOURCE_STATUS_NOTIFY ) { -drm_dp_send_up_ack_reply (mgr, mstb, msg.req_type, seqno, false); +drm_dp_send_up_ack_reply (mgr, mgr->mst_primary, msg.req_type, seqno, false); +if (!mstb) + mstb =drm_dp_get_mst_branch_device_by_guid (mgr, msg.u.resource_stat.guid); + +if (!mstb) { +DRM_DEBUG_KMS ("Got MST reply from unknown device %d\n" , mgr->up_req_recv.initial_hdr.lct); +memset (&mgr->up_req_recv,0 ,sizeof (struct drm_dp_sideband_msg_rx )); +return 0 ; + } +DRM_DEBUG_KMS ("Got RSN: pn: %d avail_pbn %d\n" , msg.u.resource_stat.port_number, msg.u.resource_stat.available_pbn); }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] drm/dp/mst: always send reply for UP request
In reply to Sasha LevinFrom: Mykola Lysenko <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1f16ee7fa13649f4e55aa48ad31c3eb0722a62d3 ]
We should always send reply for UP request in order to make downstream device clean-up resources appropriately.
Issue was that reply for UP request was sent only once.
--- drivers/gpu/drm/drm_dp_mst_topology.c | 30 +++++++++++------------------- include/drm/drm_dp_mst_helper.h | 2 -- 2 files changed, 11 insertions(+), 21 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c +11 -19
@@ -1475,26 +1475,18 @@ static void process_single_down_tx_qlock(struct drm_dp_mst_topology_mgr *mgr) }/* called holding qlock */ -static void process_single_up_tx_qlock (struct drm_dp_mst_topology_mgr *mgr) +static void process_single_up_tx_qlock (struct drm_dp_mst_topology_mgr *mgr, +struct drm_dp_sideband_msg_tx *txmsg) { -struct drm_dp_sideband_msg_tx *txmsg;int ret;/* construct a chunk from the first msg in the tx_msg queue */ -if (list_empty (&mgr->tx_msg_upq)) { - mgr->tx_up_in_progress = false; -return ; - } - - txmsg = list_first_entry(&mgr->tx_msg_upq, struct drm_dp_sideband_msg_tx, next); ret =process_single_tx_qlock (mgr, txmsg, true); -if (ret ==1 ) { -/* up txmsgs aren't put in slots - so free after we send it */ -list_del (&txmsg->next); -kfree (txmsg); - }else if (ret) + +if (ret !=1 )DRM_DEBUG_KMS ("failed to send msg in q %d\n" , ret); - mgr->tx_up_in_progress = true; + + txmsg->dst->tx_slots[txmsg->seqno] =NULL ; } static void drm_dp_queue_down_tx(struct drm_dp_mst_topology_mgr *mgr,
@@ -1879,11 +1871,12 @@ static int drm_dp_send_up_ack_reply(struct drm_dp_mst_topology_mgr *mgr,drm_dp_encode_up_ack_reply (txmsg, req_type);mutex_lock (&mgr->qlock); -list_add_tail (&txmsg->next, &mgr->tx_msg_upq); -if (!mgr->tx_up_in_progress) { -process_single_up_tx_qlock (mgr); - } + +process_single_up_tx_qlock (mgr, txmsg); +mutex_unlock (&mgr->qlock); + +kfree (txmsg);return 0 ; }
@@ -2774,7 +2767,6 @@ int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr,mutex_init (&mgr->qlock);mutex_init (&mgr->payload_lock);mutex_init (&mgr->destroy_connector_lock); -INIT_LIST_HEAD (&mgr->tx_msg_upq);INIT_LIST_HEAD (&mgr->tx_msg_downq);INIT_LIST_HEAD (&mgr->destroy_connector_list);INIT_WORK (&mgr->work, drm_dp_mst_link_probe_work);
include/drm/drm_dp_mst_helper.h +0 -2
@@ -449,9 +449,7 @@ struct drm_dp_mst_topology_mgr {the mstb tx_slots and txmsg->state once they are queued */ struct mutex qlock;struct list_head tx_msg_downq; -struct list_head tx_msg_upq;bool tx_down_in_progress; -bool tx_up_in_progress;/* payload info + lock for it */ struct mutex payload_lock;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] udf: Prevent buffer overrun with multi-byte characters
In reply to Sasha LevinFrom: Andrew Gabbasov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ad402b265ecf6fa22d04043b41444cdfcdf4f52d ]
udf_CS0toUTF8 function stops the conversion when the output buffer length reaches UDF_NAME_LEN-2, which is correct maximum name length, but, when checking, it leaves the space for a single byte only, while multi-bytes output characters can take more space, causing buffer overflow.
Similar error exists in udf_CS0toNLS function, that restricts the output length to UDF_NAME_LEN, while actual maximum allowed length is UDF_NAME_LEN-2.
In these cases the output can override not only the current buffer length field, causing corruption of the name buffer itself, but also following allocation structures, causing kernel crash.
Adjust the output length checks in both functions to prevent buffer overruns in case of multi-bytes UTF8 or NLS characters.
--- fs/udf/unicode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/udf/unicode.c +5 -1
@@ -133,11 +133,15 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)if (c <0x80U ) utf_o->u_name[utf_o->u_len++] = (uint8_t )c;else if (c <0x800U ) { +if (utf_o->u_len > (UDF_NAME_LEN -4 )) +break ; utf_o->u_name[utf_o->u_len++] = (uint8_t )(0xc0 | (c >>6 )); utf_o->u_name[utf_o->u_len++] = (uint8_t )(0x80 | (c &0x3f )); }else { +if (utf_o->u_len > (UDF_NAME_LEN -5 )) +break ; utf_o->u_name[utf_o->u_len++] = (uint8_t )(0xe0 | (c >>12 )); utf_o->u_name[utf_o->u_len++] =
@@ -282,7 +286,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, c = (c <<8 ) | ocu[i++]; len = nls->uni2char (c, &utf_o->u_name[utf_o->u_len], -UDF_NAME_LEN - utf_o->u_len); +UDF_NAME_LEN -2 - utf_o->u_len);/* Valid character? */ if (len >=0 ) utf_o->u_len += len;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] udf: Check output buffer length when converting name to CS0
In reply to Sasha LevinFrom: Andrew Gabbasov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bb00c898ad1ce40c4bb422a8207ae562e9aea7ae ]
If a name contains at least some characters with Unicode values exceeding single byte, the CS0 output should have 2 bytes per character. And if other input characters have single byte Unicode values, then the single input byte is converted to 2 output bytes, and the length of output becomes larger than the length of input. And if the input name is long enough, the output length may exceed the allocated buffer length.
All this means that conversion from UTF8 or NLS to CS0 requires checking of output length in order to stop when it exceeds the given output buffer size.
[JK: Make code return -ENAMETOOLONG instead of silently truncating the name]
--- fs/udf/unicode.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
fs/udf/unicode.c +13 -2
@@ -182,17 +182,22 @@ int udf_CS0toUTF8(struct ustr *utf_o, const struct ustr *ocu_i)static int udf_UTF8toCS0 (dstring *ocu,struct ustr *utf,int length) {unsigned c, i, max_val, utf_char; -int utf_cnt, u_len; +int utf_cnt, u_len, u_ch;memset (ocu,0 ,sizeof (dstring) * length); ocu[0 ] =8 ; max_val =0xffU ; + u_ch =1 ; try_again: u_len =0U ; utf_char =0U ; utf_cnt =0U ;for (i =0U ; i < utf->u_len; i++) { +/* Name didn't fit? */ +if (u_len +1 + u_ch >= length) +return 0 ; + c = (uint8_t )utf->u_name[i];/* Complete a multi-byte UTF-8 character */
@@ -234,6 +239,7 @@ try_again:if (max_val ==0xffU ) { max_val =0xffffU ; ocu[0 ] = (uint8_t )0x10U ; + u_ch =2 ; goto try_again; } goto error_out;
@@ -304,15 +310,19 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni,int len;unsigned i, max_val;uint16_t uni_char; -int u_len; +int u_len, u_ch;memset (ocu,0 ,sizeof (dstring) * length); ocu[0 ] =8 ; max_val =0xffU ; + u_ch =1 ; try_again: u_len =0U ;for (i =0U ; i < uni->u_len; i++) { +/* Name didn't fit? */ +if (u_len +1 + u_ch >= length) +return 0 ; len = nls->char2uni (&uni->u_name[i], uni->u_len - i, &uni_char);if (!len)continue ;
@@ -325,6 +335,7 @@ try_again:if (uni_char > max_val) { max_val =0xffffU ; ocu[0 ] = (uint8_t )0x10U ; + u_ch =2 ; goto try_again; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] drm/dp/mst: fix in MSTB RAD initialization
In reply to Sasha LevinFrom: Mykola Lysenko <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 75af4c8c4c0f60d7ad135419805798f144e9baf9 ]
This fix is needed to support more then two
branch displays, so RAD address consist at
least of 2 elements
--- drivers/gpu/drm/drm_dp_mst_topology.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c +6 -6
@@ -968,17 +968,17 @@ static struct drm_dp_mst_port *drm_dp_get_port(struct drm_dp_mst_branch *mstb, ustatic u8 drm_dp_calculate_rad (struct drm_dp_mst_port *port,u8 *rad) { -int lct = port->parent->lct; +int parent_lct = port->parent->lct;int shift =4 ; -int idx = lct /2 ; -if (lct >1 ) { -memcpy (rad, port->parent->rad, idx); - shift = (lct %2 ) ?4 :0 ; +int idx = (parent_lct -1 ) /2 ; +if (parent_lct >1 ) { +memcpy (rad, port->parent->rad, idx +1 ); + shift = (parent_lct %2 ) ?4 :0 ; }else rad[0 ] =0 ; rad[idx] |= port->port_num << shift; -return lct +1 ; +return parent_lct +1 ; }/*
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] posix-clock: Fix return code on the poll method's error path
In reply to Sasha LevinFrom: Richard Cochran <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1b9f23727abb92c5e58f139e7d180befcaa06fe0 ]
The posix_clock_poll function is supposed to return a bit mask of POLLxxx values. However, in case the hardware has disappeared (due to hot plugging for example) this code returns -ENODEV in a futile attempt to throw an error at the file descriptor level. The kernel's file_operations interface does not accept such error codes from the poll method. Instead, this function aught to return POLLERR.
The value -ENODEV does, in fact, contain the POLLERR bit (and almost all the other POLLxxx bits as well), but only by chance. This patch fixes code to return a proper bit mask.
Credit goes to Markus Elfring for pointing out the suspicious signed/unsigned mismatch.
--- kernel/time/posix-clock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/time/posix-clock.c +2 -2
@@ -69,10 +69,10 @@ static ssize_t posix_clock_read(struct file *fp, char __user *buf,static unsigned int posix_clock_poll (struct file *fp,poll_table *wait) {struct posix_clock *clk =get_posix_clock (fp); -int result =0 ; +unsigned int result =0 ;if (!clk) -return -ENODEV ; +return POLLERR ;if (clk->ops.poll) result = clk->ops.poll (clk, fp, wait);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] drm/dp/mst: fix in RAD element access
In reply to Sasha LevinFrom: Mykola Lysenko <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7a11a334aa6af4c65c6a0d81b60c97fc18673532 ]
This is needed to receive correct port
number from RAD, so MSTB could be found
--- drivers/gpu/drm/drm_dp_mst_topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_dp_mst_topology.c +2 -2
@@ -1034,7 +1034,7 @@ static void build_mst_prop_path(struct drm_dp_mst_port *port,snprintf (proppath, proppath_size,"mst:%d" , mstb->mgr->conn_base_id);for (i =0 ; i < (mstb->lct -1 ); i++) {int shift = (i %2 ) ?0 :4 ; -int port_num = mstb->rad[i /2 ] >> shift; +int port_num = (mstb->rad[i /2 ] >> shift) &0xf ;snprintf (temp,sizeof (temp),"-%d" , port_num);strlcat (proppath, temp, proppath_size); }
@@ -1175,7 +1175,7 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_for (i =0 ; i < lct -1 ; i++) {int shift = (i %2 ) ?0 :4 ; -int port_num = rad[i /2 ] >> shift; +int port_num = (rad[i /2 ] >> shift) &0xf ;list_for_each_entry (port, &mstb->ports, next) {if (port->port_num == port_num) {
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] iwlwifi: update and fix 7265 series PCI IDs
In reply to Sasha LevinThis patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 006bda75d81fd27a583a3b310e9444fea2aa6ef2 ]
Update and fix some 7265 PCI IDs entries.
--- drivers/net/wireless/iwlwifi/pcie/drv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/iwlwifi/pcie/drv.c +3 -2
@@ -382,6 +382,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = { {IWL_PCI_DEVICE(0x095B, 0x5310, iwl7265_2ac_cfg)}, {IWL_PCI_DEVICE(0x095B, 0x5302, iwl7265_n_cfg)}, {IWL_PCI_DEVICE(0x095B, 0x5210, iwl7265_2ac_cfg)}, + {IWL_PCI_DEVICE(0x095A, 0x5C10, iwl7265_2ac_cfg)}, {IWL_PCI_DEVICE(0x095A, 0x5012, iwl7265_2ac_cfg)}, {IWL_PCI_DEVICE(0x095A, 0x5412, iwl7265_2ac_cfg)}, {IWL_PCI_DEVICE(0x095A, 0x5410, iwl7265_2ac_cfg)},
@@ -399,10 +400,10 @@ static const struct pci_device_id iwl_hw_card_ids[] = { {IWL_PCI_DEVICE(0x095A, 0x900A, iwl7265_2ac_cfg)}, {IWL_PCI_DEVICE(0x095A, 0x9110, iwl7265_2ac_cfg)}, {IWL_PCI_DEVICE(0x095A, 0x9112, iwl7265_2ac_cfg)}, - {IWL_PCI_DEVICE(0x095A, 0x9210, iwl7265_2ac_cfg)}, + {IWL_PCI_DEVICE(0x095B, 0x9210, iwl7265_2ac_cfg)}, {IWL_PCI_DEVICE(0x095B, 0x9200, iwl7265_2ac_cfg)}, {IWL_PCI_DEVICE(0x095A, 0x9510, iwl7265_2ac_cfg)}, - {IWL_PCI_DEVICE(0x095A, 0x9310, iwl7265_2ac_cfg)}, + {IWL_PCI_DEVICE(0x095B, 0x9310, iwl7265_2ac_cfg)}, {IWL_PCI_DEVICE(0x095A, 0x9410, iwl7265_2ac_cfg)}, {IWL_PCI_DEVICE(0x095A, 0x5020, iwl7265_2n_cfg)}, {IWL_PCI_DEVICE(0x095A, 0x502A, iwl7265_2n_cfg)},
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] iwlwifi: pcie: properly configure the debug buffer size for 8000
In reply to Sasha LevinFrom: Emmanuel Grumbach <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 62d7476d958ce06d7a10b02bdb30006870286fe2 ]
8000 device family has a new debug engine that needs to be configured differently than 7000's.
The debug engine's DMA works in chunks of memory and the size of the buffer really means the start of the last chunk. Since one chunk is 256-byte long, we should configure the device to write to buffer_size - 256. This fixes a situation were the device would write to memory it is not allowed to access.
---
.../net/wireless/{ => intel}/iwlwifi/pcie/trans.c | 803 ++++++++++++---------
drivers/net/wireless/iwlwifi/pcie/trans.c | 15 +-
2 files changed, 462 insertions(+), 356 deletions(-)
copy drivers/net/wireless/{ => intel}/iwlwifi/pcie/trans.c (85%)drivers/net/wireless/intel/iwlwifi/pcie/trans.c renamed from drivers/net/wireless/iwlwifi/pcie/trans.c +450 -353
@@ -7,6 +7,7 @@* * Copyright(c) 2007 - 2015 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH +* Copyright(c) 2016 Intel Deutschland GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as
@@ -26,13 +27,14 @@* in the file called COPYING. * * Contact Information: -* Intel Linux Wireless <[email protected]> +* Intel Linux Wireless <[email protected]> * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 * * BSD LICENSE * * Copyright(c) 2005 - 2015 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH +* Copyright(c) 2016 Intel Deutschland GmbH * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -101,14 +103,26 @@ static void iwl_pcie_free_fw_monitor(struct iwl_trans *trans) trans_pcie->fw_mon_size =0 ; } -static void iwl_pcie_alloc_fw_monitor (struct iwl_trans *trans) +static void iwl_pcie_alloc_fw_monitor (struct iwl_trans *trans,u8 max_power) {struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans);struct page *page =NULL ;dma_addr_t phys; -u32 size; +u32 size =0 ;u8 power; +if (!max_power) { +/* default max_power is maximum */ + max_power =26 ; + }else { + max_power +=11 ; + } + +if (WARN (max_power >26 , +"External buffer size for monitor is too big %d, check the FW TLV\n" , + max_power)) +return ; +if (trans_pcie->fw_mon_page) { dma_sync_single_for_device(trans->dev, trans_pcie->fw_mon_phys, trans_pcie->fw_mon_size,
@@ -117,7 +131,7 @@ static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans) } phys =0 ; -for (power =26 ; power >=11 ; power--) { +for (power = max_power; power >=11 ; power--) {int order; size =BIT (power);
@@ -143,6 +157,12 @@ static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans)if (WARN_ON_ONCE (!page))return ; +if (power != max_power) +IWL_ERR (trans, +"Sorry - debug buffer is only %luK while you requested %luK\n" , + (unsigned long )BIT (power -10 ), + (unsigned long )BIT (max_power -10 )); + trans_pcie->fw_mon_page = page; trans_pcie->fw_mon_phys = phys; trans_pcie->fw_mon_size = size;
@@ -164,6 +184,9 @@ static void iwl_trans_pcie_write_shr(struct iwl_trans *trans, u32 reg, u32 val)static void iwl_pcie_set_pwr (struct iwl_trans *trans,bool vaux) { +if (trans->cfg->apmg_not_supported) +return ; +if (vaux &&pci_pme_capable (to_pci_dev (trans->dev), PCI_D3cold)) iwl_set_bits_mask_prph(trans, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VAUX,
@@ -297,7 +320,7 @@ static int iwl_pcie_apm_init(struct iwl_trans *trans)* bits do not disable clocks. This preserves any hardware * bits already set by default in "CLK_CTRL_REG" after reset. */ -if (trans->cfg->device_family !=IWL_DEVICE_FAMILY_8000 ) { +if (!trans->cfg->apmg_not_supported) {iwl_write_prph (trans,APMG_CLK_EN_REG ,APMG_CLK_VAL_DMA_CLK_RQT );udelay (20 );
@@ -503,8 +526,7 @@ static int iwl_pcie_nic_init(struct iwl_trans *trans)spin_unlock (&trans_pcie->irq_lock); -if (trans->cfg->device_family !=IWL_DEVICE_FAMILY_8000 ) -iwl_pcie_set_pwr (trans, false); +iwl_pcie_set_pwr (trans, false);iwl_op_mode_nic_config (trans->op_mode);
@@ -754,8 +776,15 @@ static int iwl_pcie_load_cpu_sections_8000(struct iwl_trans *trans,for (i = *first_ucode_section; i <IWL_UCODE_SECTION_MAX ; i++) { last_read_idx = i; +/* +* CPU1_CPU2_SEPARATOR_SECTION delimiter - separate between +* CPU1 to CPU2. +* PAGING_SEPARATOR_SECTION delimiter - separate between +* CPU2 non paged to CPU2 paging sec. +*/ if (!image->sec[i].data || - image->sec[i].offset ==CPU1_CPU2_SEPARATOR_SECTION ) { + image->sec[i].offset ==CPU1_CPU2_SEPARATOR_SECTION || + image->sec[i].offset ==PAGING_SEPARATOR_SECTION ) {IWL_DEBUG_FW (trans,"Break since Data not valid or Empty section, sec = %d\n" , i);
@@ -803,8 +832,15 @@ static int iwl_pcie_load_cpu_sections(struct iwl_trans *trans,for (i = *first_ucode_section; i <IWL_UCODE_SECTION_MAX ; i++) { last_read_idx = i; +/* +* CPU1_CPU2_SEPARATOR_SECTION delimiter - separate between +* CPU1 to CPU2. +* PAGING_SEPARATOR_SECTION delimiter - separate between +* CPU2 non paged to CPU2 paging sec. +*/ if (!image->sec[i].data || - image->sec[i].offset ==CPU1_CPU2_SEPARATOR_SECTION ) { + image->sec[i].offset ==CPU1_CPU2_SEPARATOR_SECTION || + image->sec[i].offset ==PAGING_SEPARATOR_SECTION ) {IWL_DEBUG_FW (trans,"Break since Data not valid or Empty section, sec = %d\n" , i);
@@ -844,7 +880,7 @@ static void iwl_pcie_apply_destination(struct iwl_trans *trans) get_fw_dbg_mode_string(dest->monitor_mode));if (dest->monitor_mode ==EXTERNAL_MODE ) -iwl_pcie_alloc_fw_monitor (trans); +iwl_pcie_alloc_fw_monitor (trans, dest->size_power);else IWL_WARN (trans,"PCI should have external buffer debug\n" );
@@ -871,6 +907,14 @@ static void iwl_pcie_apply_destination(struct iwl_trans *trans)case PRPH_CLEARBIT :iwl_clear_bits_prph (trans, addr,BIT (val));break ; +case PRPH_BLOCKBIT : +if (iwl_read_prph (trans, addr) &BIT (val)) { +IWL_ERR (trans, +"BIT(%u) in address 0x%x is 1, stopping FW configuration\n" , + val, addr); + goto monitor; + } +break ;default :IWL_ERR (trans,"FW debug - unknown OP %d\n" , dest->reg_ops[i].op);
@@ -878,12 +922,20 @@ static void iwl_pcie_apply_destination(struct iwl_trans *trans) } } +monitor:if (dest->monitor_mode ==EXTERNAL_MODE && trans_pcie->fw_mon_size) {iwl_write_prph (trans,le32_to_cpu (dest->base_reg), trans_pcie->fw_mon_phys >> dest->base_shift); -iwl_write_prph (trans,le32_to_cpu (dest->end_reg), - (trans_pcie->fw_mon_phys + - trans_pcie->fw_mon_size) >> dest->end_shift); +if (trans->cfg->device_family ==IWL_DEVICE_FAMILY_8000 ) +iwl_write_prph (trans,le32_to_cpu (dest->end_reg), + (trans_pcie->fw_mon_phys + + trans_pcie->fw_mon_size -256 ) >> + dest->end_shift); +else +iwl_write_prph (trans,le32_to_cpu (dest->end_reg), + (trans_pcie->fw_mon_phys + + trans_pcie->fw_mon_size) >> + dest->end_shift); } }
@@ -918,7 +970,7 @@ static int iwl_pcie_load_given_ucode(struct iwl_trans *trans,/* supported for 7000 only for the moment */ if (iwlwifi_mod_params.fw_monitor && trans->cfg->device_family ==IWL_DEVICE_FAMILY_7000 ) { -iwl_pcie_alloc_fw_monitor (trans); +iwl_pcie_alloc_fw_monitor (trans,0 );if (trans_pcie->fw_mon_size) { iwl_write_prph(trans, MON_BUFF_BASE_ADDR,
@@ -965,24 +1017,32 @@ static int iwl_pcie_load_given_ucode_8000(struct iwl_trans *trans,return ret;/* load to FW the binary sections of CPU2 */ - ret =iwl_pcie_load_cpu_sections_8000 (trans, image,2 , - &first_ucode_section); -if (ret) -return ret; - -return 0 ; +return iwl_pcie_load_cpu_sections_8000 (trans, image,2 , + &first_ucode_section); }static int iwl_trans_pcie_start_fw (struct iwl_trans *trans,const struct fw_img *fw,bool run_in_rfkill) { -int ret; +struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans);bool hw_rfkill; +int ret; + +mutex_lock (&trans_pcie->mutex); + +/* Someone called stop_device, don't try to start_fw */ +if (trans_pcie->is_down) { +IWL_WARN (trans, +"Can't start_fw since the HW hasn't been started\n" ); + ret =EIO ; + goto out; + }/* This may fail if AMT took ownership of the device */ if (iwl_pcie_prepare_card_hw (trans)) {IWL_WARN (trans,"Exit HW not ready\n" ); -return -EIO ; + ret = -EIO ; + goto out; }iwl_enable_rfkill_int (trans);
@@ -994,15 +1054,17 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans,else clear_bit (STATUS_RFKILL , &trans->status);iwl_trans_pcie_rf_kill (trans, hw_rfkill); -if (hw_rfkill && !run_in_rfkill) -return -ERFKILL ; +if (hw_rfkill && !run_in_rfkill) { + ret = -ERFKILL ; + goto out; + }iwl_write32 (trans,CSR_INT ,0xFFFFFFFF ); ret =iwl_pcie_nic_init (trans);if (ret) {IWL_ERR (trans,"Unable to init nic\n" ); -return ret; + goto out; }/* make sure rfkill handshake bits are cleared */
@@ -1020,9 +1082,13 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans,/* Load the given image to the HW */ if (trans->cfg->device_family ==IWL_DEVICE_FAMILY_8000 ) -return iwl_pcie_load_given_ucode_8000 (trans, fw); + ret =iwl_pcie_load_given_ucode_8000 (trans, fw);else -return iwl_pcie_load_given_ucode (trans, fw); + ret =iwl_pcie_load_given_ucode (trans, fw); + +out: +mutex_unlock (&trans_pcie->mutex); +return ret; }static void iwl_trans_pcie_fw_alive (struct iwl_trans *trans,u32 scd_addr)
@@ -1031,11 +1097,18 @@ static void iwl_trans_pcie_fw_alive(struct iwl_trans *trans, u32 scd_addr)iwl_pcie_tx_start (trans, scd_addr); } -static void iwl_trans_pcie_stop_device (struct iwl_trans *trans,bool low_power) +static void _iwl_trans_pcie_stop_device (struct iwl_trans *trans,bool low_power) {struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans);bool hw_rfkill, was_hw_rfkill; +lockdep_assert_held (&trans_pcie->mutex); + +if (trans_pcie->is_down) +return ; + + trans_pcie->is_down = true; + was_hw_rfkill =iwl_is_rfkill_set (trans);/* tell the device to stop sending interrupts */
@@ -1059,7 +1132,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)iwl_pcie_rx_stop (trans);/* Power-down device's busmaster DMA clocks */ -if (trans->cfg->device_family !=IWL_DEVICE_FAMILY_8000 ) { +if (!trans->cfg->apmg_not_supported) {iwl_write_prph (trans,APMG_CLK_DIS_REG ,APMG_CLK_VAL_DMA_CLK_RQT );udelay (5 );
@@ -1125,14 +1198,36 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)iwl_pcie_prepare_card_hw (trans); } +static void iwl_trans_pcie_stop_device (struct iwl_trans *trans,bool low_power) +{ +struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); + +mutex_lock (&trans_pcie->mutex); +_iwl_trans_pcie_stop_device (trans, low_power); +mutex_unlock (&trans_pcie->mutex); +} +void iwl_trans_pcie_rf_kill (struct iwl_trans *trans,bool state) { +struct iwl_trans_pcie __maybe_unused *trans_pcie = +IWL_TRANS_GET_PCIE_TRANS (trans); + +lockdep_assert_held (&trans_pcie->mutex); +if (iwl_op_mode_hw_rf_kill (trans->op_mode, state)) -iwl_trans_pcie_stop_device (trans, true); +_iwl_trans_pcie_stop_device (trans, true); }static void iwl_trans_pcie_d3_suspend (struct iwl_trans *trans,bool test) { +struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); + +if (trans->system_pm_mode ==IWL_PLAT_PM_MODE_D0I3 ) { +/* Enable persistence mode to avoid reset */ +iwl_set_bit (trans,CSR_HW_IF_CONFIG_REG , +CSR_HW_IF_CONFIG_REG_PERSIST_MODE ); + } +iwl_disable_interrupts (trans);/*
@@ -1144,17 +1239,21 @@ static void iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool test)iwl_pcie_disable_ict (trans); +synchronize_irq (trans_pcie->pci_dev->irq); +iwl_clear_bit (trans,CSR_GP_CNTRL ,CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ );iwl_clear_bit (trans,CSR_GP_CNTRL ,CSR_GP_CNTRL_REG_FLAG_INIT_DONE ); -/* -* reset TX queues -- some of their registers reset during S3 -* so if we don't reset everything here the D3 image would try -* to execute some invalid memory upon resume -*/ -iwl_trans_pcie_tx_reset (trans); +if (trans->system_pm_mode ==IWL_PLAT_PM_MODE_D3 ) { +/* +* reset TX queues -- some of their registers reset during S3 +* so if we don't reset everything here the D3 image would try +* to execute some invalid memory upon resume +*/ +iwl_trans_pcie_tx_reset (trans); + }iwl_pcie_set_pwr (trans, true); }
@@ -1196,12 +1295,18 @@ static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,iwl_pcie_set_pwr (trans, false); -iwl_trans_pcie_tx_reset (trans); +if (trans->system_pm_mode ==IWL_PLAT_PM_MODE_D0I3 ) { +iwl_clear_bit (trans,CSR_GP_CNTRL , +CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ ); + }else { +iwl_trans_pcie_tx_reset (trans); - ret =iwl_pcie_rx_init (trans); -if (ret) { -IWL_ERR (trans,"Failed to resume the device (RX reset)\n" ); -return ret; + ret =iwl_pcie_rx_init (trans); +if (ret) { +IWL_ERR (trans, +"Failed to resume the device (RX reset)\n" ); +return ret; + } } val =iwl_read32 (trans,CSR_RESET );
@@ -1213,11 +1318,14 @@ static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,return 0 ; } -static int iwl_trans_pcie_start_hw (struct iwl_trans *trans,bool low_power) +static int _iwl_trans_pcie_start_hw (struct iwl_trans *trans,bool low_power) { +struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans);bool hw_rfkill;int err; +lockdep_assert_held (&trans_pcie->mutex); + err =iwl_pcie_prepare_card_hw (trans);if (err) {IWL_ERR (trans,"Error while preparing HW: %d\n" , err);
@@ -1234,20 +1342,38 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans, bool low_power)/* From now on, the op_mode will be kept updated about RF kill state */ iwl_enable_rfkill_int (trans); +/* Set is_down to false here so that...*/ + trans_pcie->is_down = false; + hw_rfkill =iwl_is_rfkill_set (trans);if (hw_rfkill)set_bit (STATUS_RFKILL , &trans->status);else clear_bit (STATUS_RFKILL , &trans->status); +/* ... rfkill can call stop_device and set it false if needed */ iwl_trans_pcie_rf_kill (trans, hw_rfkill);return 0 ; } +static int iwl_trans_pcie_start_hw (struct iwl_trans *trans,bool low_power) +{ +struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); +int ret; + +mutex_lock (&trans_pcie->mutex); + ret =_iwl_trans_pcie_start_hw (trans, low_power); +mutex_unlock (&trans_pcie->mutex); + +return ret; +} +static void iwl_trans_pcie_op_mode_leave (struct iwl_trans *trans) {struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); +mutex_lock (&trans_pcie->mutex); +/* disable interrupts - don't enable HW RF kill interrupt */ spin_lock (&trans_pcie->irq_lock);iwl_disable_interrupts (trans);
@@ -1260,6 +1386,10 @@ static void iwl_trans_pcie_op_mode_leave(struct iwl_trans *trans)spin_unlock (&trans_pcie->irq_lock);iwl_pcie_disable_ict (trans); + +mutex_unlock (&trans_pcie->mutex); + +synchronize_irq (trans_pcie->pci_dev->irq); }static void iwl_trans_pcie_write8 (struct iwl_trans *trans,u32 ofs,u8 val)
@@ -1314,15 +1444,17 @@ static void iwl_trans_pcie_configure(struct iwl_trans *trans,memcpy (trans_pcie->no_reclaim_cmds, trans_cfg->no_reclaim_cmds, trans_pcie->n_no_reclaim_cmds *sizeof (u8)); - trans_pcie->rx_buf_size_8k = trans_cfg->rx_buf_size_8k; -if (trans_pcie->rx_buf_size_8k) - trans_pcie->rx_page_order =get_order (8 *1024 ); -else - trans_pcie->rx_page_order =get_order (4 *1024 ); + trans_pcie->rx_buf_size = trans_cfg->rx_buf_size; + trans_pcie->rx_page_order = +iwl_trans_get_rb_size_order (trans_pcie->rx_buf_size); - trans_pcie->command_names = trans_cfg->command_names; + trans_pcie->wide_cmd_header = trans_cfg->wide_cmd_header; trans_pcie->bc_table_dword = trans_cfg->bc_table_dword; trans_pcie->scd_set_active = trans_cfg->scd_set_active; + trans_pcie->sw_csum_tx = trans_cfg->sw_csum_tx; + + trans->command_groups = trans_cfg->command_groups; + trans->command_groups_size = trans_cfg->command_groups_size;/* init ref_count to 1 (should be cleared when ucode is loaded) */ trans_pcie->ref_count =1 ;
@@ -1332,17 +1464,17 @@ static void iwl_trans_pcie_configure(struct iwl_trans *trans,* As this function may be called again in some corner cases don't * do anything if NAPI was already initialized. */ -if (!trans_pcie->napi.poll && trans->op_mode->ops->napi_add) { +if (!trans_pcie->napi.poll) {init_dummy_netdev (&trans_pcie->napi_dev); -iwl_op_mode_napi_add (trans->op_mode, &trans_pcie->napi, - &trans_pcie->napi_dev, - iwl_pcie_dummy_napi_poll,64 ); +netif_napi_add (&trans_pcie->napi_dev, &trans_pcie->napi, + iwl_pcie_dummy_napi_poll,64 ); } }void iwl_trans_pcie_free (struct iwl_trans *trans) {struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); +int i;synchronize_irq (trans_pcie->pci_dev->irq);
@@ -1356,14 +1488,22 @@ void iwl_trans_pcie_free(struct iwl_trans *trans)iounmap (trans_pcie->hw_base);pci_release_regions (trans_pcie->pci_dev);pci_disable_device (trans_pcie->pci_dev); -kmem_cache_destroy (trans->dev_cmd_pool);if (trans_pcie->napi.poll)netif_napi_del (&trans_pcie->napi);iwl_pcie_free_fw_monitor (trans); -kfree (trans); +for_each_possible_cpu (i) { +struct iwl_tso_hdr_page *p = +per_cpu_ptr (trans_pcie->tso_hdr_page, i); + +if (p->page) +__free_page (p->page); + } + +free_percpu (trans_pcie->tso_hdr_page); +iwl_trans_free (trans); }static void iwl_trans_pcie_set_pmi (struct iwl_trans *trans,bool state)
@@ -1374,8 +1514,8 @@ static void iwl_trans_pcie_set_pmi(struct iwl_trans *trans, bool state)clear_bit (STATUS_TPOWER_PMI , &trans->status); } -static bool iwl_trans_pcie_grab_nic_access (struct iwl_trans *trans,bool silent, -unsigned long *flags) +static bool iwl_trans_pcie_grab_nic_access (struct iwl_trans *trans, +unsigned long *flags) {int ret;struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans);
@@ -1416,14 +1556,11 @@ static bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans, bool silent, CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000);if (unlikely (ret <0 )) {iwl_write32 (trans,CSR_RESET ,CSR_RESET_REG_FLAG_FORCE_NMI ); -if (!silent) { -u32 val =iwl_read32 (trans,CSR_GP_CNTRL ); -WARN_ONCE (1 , -"Timeout waiting for hardware access (CSR_GP_CNTRL 0x%08x)\n" , - val); -spin_unlock_irqrestore (&trans_pcie->reg_lock, *flags); -return false; - } +WARN_ONCE (1 , +"Timeout waiting for hardware access (CSR_GP_CNTRL 0x%08x)\n" , +iwl_read32 (trans,CSR_GP_CNTRL )); +spin_unlock_irqrestore (&trans_pcie->reg_lock, *flags); +return false; } out:
@@ -1471,7 +1608,7 @@ static int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr,int offs, ret =0 ;u32 *vals = buf; -if (iwl_trans_grab_nic_access (trans, false, &flags)) { +if (iwl_trans_grab_nic_access (trans, &flags)) {iwl_write32 (trans,HBUS_TARG_MEM_RADDR , addr);for (offs =0 ; offs < dwords; offs++) vals[offs] =iwl_read32 (trans,HBUS_TARG_MEM_RDAT );
@@ -1489,7 +1626,7 @@ static int iwl_trans_pcie_write_mem(struct iwl_trans *trans, u32 addr,int offs, ret =0 ;const u32 *vals = buf; -if (iwl_trans_grab_nic_access (trans, false, &flags)) { +if (iwl_trans_grab_nic_access (trans, &flags)) {iwl_write32 (trans,HBUS_TARG_MEM_WADDR , addr);for (offs =0 ; offs < dwords; offs++) iwl_write32(trans, HBUS_TARG_MEM_WDAT,
@@ -1555,6 +1692,33 @@ next_queue: } } +static void iwl_trans_pcie_block_txq_ptrs (struct iwl_trans *trans,bool block) +{ +struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); +int i; + +for (i =0 ; i < trans->cfg->base_params->num_of_queues; i++) { +struct iwl_txq *txq = &trans_pcie->txq[i]; + +if (i == trans_pcie->cmd_queue) +continue ; + +spin_lock_bh (&txq->lock); + +if (!block && !(WARN_ON_ONCE (!txq->block))) { + txq->block--; +if (!txq->block) { +iwl_write32 (trans,HBUS_TARG_WRPTR , + txq->q.write_ptr | (i <<8 )); + } + }else if (block) { + txq->block++; + } + +spin_unlock_bh (&txq->lock); + } +} +#define IWL_FLUSH_WAIT_MS 2000static int iwl_trans_pcie_wait_txq_empty (struct iwl_trans *trans,u32 txq_bm)
@@ -1989,13 +2153,11 @@ DEBUGFS_READ_FILE_OPS(rx_queue);DEBUGFS_READ_FILE_OPS (tx_queue);DEBUGFS_WRITE_FILE_OPS (csr); -/* -* Create the debugfs files and directories -* -*/ -static int iwl_trans_pcie_dbgfs_register (struct iwl_trans *trans, -struct dentry *dir) +/* Create the debugfs files and directories */ +int iwl_trans_pcie_dbgfs_register (struct iwl_trans *trans) { +struct dentry *dir = trans->dbgfs_dir; +DEBUGFS_ADD_FILE (rx_queue, dir,S_IRUSR );DEBUGFS_ADD_FILE (tx_queue, dir,S_IRUSR );DEBUGFS_ADD_FILE (interrupt, dir,S_IWUSR |S_IRUSR );
@@ -2007,12 +2169,6 @@ err:IWL_ERR (trans,"failed to create the trans debugfs entry\n" ); return -ENOMEM; } -#else -static int iwl_trans_pcie_dbgfs_register (struct iwl_trans *trans, -struct dentry *dir) -{ -return 0 ; -}#endif /*CONFIG_IWLWIFI_DEBUGFS */ static u32 iwl_trans_pcie_get_cmdlen (struct iwl_tfd *tfd)
@@ -2026,144 +2182,47 @@ static u32 iwl_trans_pcie_get_cmdlen(struct iwl_tfd *tfd)return cmdlen; } -static const struct { -u32 start, end; -} iwl_prph_dump_addr[] = { - { .start =0x00a00000 , .end =0x00a00000 }, - { .start =0x00a0000c , .end =0x00a00024 }, - { .start =0x00a0002c , .end =0x00a0003c }, - { .start =0x00a00410 , .end =0x00a00418 }, - { .start =0x00a00420 , .end =0x00a00420 }, - { .start =0x00a00428 , .end =0x00a00428 }, - { .start =0x00a00430 , .end =0x00a0043c }, - { .start =0x00a00444 , .end =0x00a00444 }, - { .start =0x00a004c0 , .end =0x00a004cc }, - { .start =0x00a004d8 , .end =0x00a004d8 }, - { .start =0x00a004e0 , .end =0x00a004f0 }, - { .start =0x00a00840 , .end =0x00a00840 }, - { .start =0x00a00850 , .end =0x00a00858 }, - { .start =0x00a01004 , .end =0x00a01008 }, - { .start =0x00a01010 , .end =0x00a01010 }, - { .start =0x00a01018 , .end =0x00a01018 }, - { .start =0x00a01024 , .end =0x00a01024 }, - { .start =0x00a0102c , .end =0x00a01034 }, - { .start =0x00a0103c , .end =0x00a01040 }, - { .start =0x00a01048 , .end =0x00a01094 }, - { .start =0x00a01c00 , .end =0x00a01c20 }, - { .start =0x00a01c58 , .end =0x00a01c58 }, - { .start =0x00a01c7c , .end =0x00a01c7c }, - { .start =0x00a01c28 , .end =0x00a01c54 }, - { .start =0x00a01c5c , .end =0x00a01c5c }, - { .start =0x00a01c60 , .end =0x00a01cdc }, - { .start =0x00a01ce0 , .end =0x00a01d0c }, - { .start =0x00a01d18 , .end =0x00a01d20 }, - { .start =0x00a01d2c , .end =0x00a01d30 }, - { .start =0x00a01d40 , .end =0x00a01d5c }, - { .start =0x00a01d80 , .end =0x00a01d80 }, - { .start =0x00a01d98 , .end =0x00a01d9c }, - { .start =0x00a01da8 , .end =0x00a01da8 }, - { .start =0x00a01db8 , .end =0x00a01df4 }, - { .start =0x00a01dc0 , .end =0x00a01dfc }, - { .start =0x00a01e00 , .end =0x00a01e2c }, - { .start =0x00a01e40 , .end =0x00a01e60 }, - { .start =0x00a01e68 , .end =0x00a01e6c }, - { .start =0x00a01e74 , .end =0x00a01e74 }, - { .start =0x00a01e84 , .end =0x00a01e90 }, - { .start =0x00a01e9c , .end =0x00a01ec4 }, - { .start =0x00a01ed0 , .end =0x00a01ee0 }, - { .start =0x00a01f00 , .end =0x00a01f1c }, - { .start =0x00a01f44 , .end =0x00a01ffc }, - { .start =0x00a02000 , .end =0x00a02048 }, - { .start =0x00a02068 , .end =0x00a020f0 }, - { .start =0x00a02100 , .end =0x00a02118 }, - { .start =0x00a02140 , .end =0x00a0214c }, - { .start =0x00a02168 , .end =0x00a0218c }, - { .start =0x00a021c0 , .end =0x00a021c0 }, - { .start =0x00a02400 , .end =0x00a02410 }, - { .start =0x00a02418 , .end =0x00a02420 }, - { .start =0x00a02428 , .end =0x00a0242c }, - { .start =0x00a02434 , .end =0x00a02434 }, - { .start =0x00a02440 , .end =0x00a02460 }, - { .start =0x00a02468 , .end =0x00a024b0 }, - { .start =0x00a024c8 , .end =0x00a024cc }, - { .start =0x00a02500 , .end =0x00a02504 }, - { .start =0x00a0250c , .end =0x00a02510 }, - { .start =0x00a02540 , .end =0x00a02554 }, - { .start =0x00a02580 , .end =0x00a025f4 }, - { .start =0x00a02600 , .end =0x00a0260c }, - { .start =0x00a02648 , .end =0x00a02650 }, - { .start =0x00a02680 , .end =0x00a02680 }, - { .start =0x00a026c0 , .end =0x00a026d0 }, - { .start =0x00a02700 , .end =0x00a0270c }, - { .start =0x00a02804 , .end =0x00a02804 }, - { .start =0x00a02818 , .end =0x00a0281c }, - { .start =0x00a02c00 , .end =0x00a02db4 }, - { .start =0x00a02df4 , .end =0x00a02fb0 }, - { .start =0x00a03000 , .end =0x00a03014 }, - { .start =0x00a0301c , .end =0x00a0302c }, - { .start =0x00a03034 , .end =0x00a03038 }, - { .start =0x00a03040 , .end =0x00a03048 }, - { .start =0x00a03060 , .end =0x00a03068 }, - { .start =0x00a03070 , .end =0x00a03074 }, - { .start =0x00a0307c , .end =0x00a0307c }, - { .start =0x00a03080 , .end =0x00a03084 }, - { .start =0x00a0308c , .end =0x00a03090 }, - { .start =0x00a03098 , .end =0x00a03098 }, - { .start =0x00a030a0 , .end =0x00a030a0 }, - { .start =0x00a030a8 , .end =0x00a030b4 }, - { .start =0x00a030bc , .end =0x00a030bc }, - { .start =0x00a030c0 , .end =0x00a0312c }, - { .start =0x00a03c00 , .end =0x00a03c5c }, - { .start =0x00a04400 , .end =0x00a04454 }, - { .start =0x00a04460 , .end =0x00a04474 }, - { .start =0x00a044c0 , .end =0x00a044ec }, - { .start =0x00a04500 , .end =0x00a04504 }, - { .start =0x00a04510 , .end =0x00a04538 }, - { .start =0x00a04540 , .end =0x00a04548 }, - { .start =0x00a04560 , .end =0x00a0457c }, - { .start =0x00a04590 , .end =0x00a04598 }, - { .start =0x00a045c0 , .end =0x00a045f4 }, -}; - -static u32 iwl_trans_pcie_dump_prph (struct iwl_trans *trans, -struct iwl_fw_error_dump_data **data) +static u32 iwl_trans_pcie_dump_rbs (struct iwl_trans *trans, +struct iwl_fw_error_dump_data **data, +int allocated_rb_nums) { -struct iwl_fw_error_dump_prph *prph; -unsigned long flags; -u32 prph_len =0 , i; +struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); +int max_len =PAGE_SIZE << trans_pcie->rx_page_order; +struct iwl_rxq *rxq = &trans_pcie->rxq; +u32 i, r, j, rb_len =0 ; -if (!iwl_trans_grab_nic_access (trans, false, &flags)) -return 0 ; +spin_lock (&rxq->lock); + + r =le16_to_cpu (ACCESS_ONCE (rxq->rb_stts->closed_rb_num)) &0x0FFF ; + +for (i = rxq->read, j =0 ; + i != r && j < allocated_rb_nums; + i = (i +1 ) &RX_QUEUE_MASK , j++) { +struct iwl_rx_mem_buffer *rxb = rxq->queue[i]; +struct iwl_fw_error_dump_rb *rb; + +dma_unmap_page (trans->dev, rxb->page_dma, max_len, +DMA_FROM_DEVICE ); + + rb_len +=sizeof (**data) +sizeof (*rb) + max_len; + + (*data)->type =cpu_to_le32 (IWL_FW_ERROR_DUMP_RB ); + (*data)->len =cpu_to_le32 (sizeof (*rb) + max_len); + rb = (void *)(*data)->data; + rb->index =cpu_to_le32 (i); +memcpy (rb->data,page_address (rxb->page), max_len); +/* remap the page for the free benefit */ + rxb->page_dma =dma_map_page (trans->dev, rxb->page,0 , + max_len, +DMA_FROM_DEVICE ); -for (i =0 ; i <ARRAY_SIZE (iwl_prph_dump_addr); i++) { -/* The range includes both boundaries */ -int num_bytes_in_chunk = iwl_prph_dump_addr[i].end - - iwl_prph_dump_addr[i].start +4 ; -int reg; -__le32 *val; - - prph_len +=sizeof (**data) +sizeof (*prph) + num_bytes_in_chunk; - - (*data)->type =cpu_to_le32 (IWL_FW_ERROR_DUMP_PRPH ); - (*data)->len =cpu_to_le32 (sizeof (*prph) + - num_bytes_in_chunk); - prph = (void *)(*data)->data; - prph->prph_start =cpu_to_le32 (iwl_prph_dump_addr[i].start); - val = (void *)prph->data; - -for (reg = iwl_prph_dump_addr[i].start; - reg <= iwl_prph_dump_addr[i].end; - reg +=4 ) - *val++ =cpu_to_le32 (iwl_trans_pcie_read_prph (trans, - reg)); *data =iwl_fw_error_next_data (*data); } -iwl_trans_release_nic_access (trans, &flags); +spin_unlock (&rxq->lock); -return prph_len; +return rb_len; } -#define IWL_CSR_TO_DUMP (0x250) static u32 iwl_trans_pcie_dump_csr(struct iwl_trans *trans,
@@ -2193,7 +2252,7 @@ static u32 iwl_trans_pcie_fh_regs_dump(struct iwl_trans *trans,__le32 *val;int i; -if (!iwl_trans_grab_nic_access (trans, false, &flags)) +if (!iwl_trans_grab_nic_access (trans, &flags))return 0 ; (*data)->type =cpu_to_le32 (IWL_FW_ERROR_DUMP_FH_REGS );
@@ -2210,17 +2269,121 @@ static u32 iwl_trans_pcie_fh_regs_dump(struct iwl_trans *trans,return sizeof (**data) + fh_regs_len; } -static -struct iwl_trans_dump_data *iwl_trans_pcie_dump_data (struct iwl_trans *trans) +static u32 +iwl_trans_pci_dump_marbh_monitor (struct iwl_trans *trans, +struct iwl_fw_error_dump_fw_mon *fw_mon_data, +u32 monitor_len) +{ +u32 buf_size_in_dwords = (monitor_len >>2 ); +u32 *buffer = (u32 *)fw_mon_data->data; +unsigned long flags; +u32 i; + +if (!iwl_trans_grab_nic_access (trans, &flags)) +return 0 ; + +iwl_write_prph_no_grab (trans,MON_DMARB_RD_CTL_ADDR ,0x1 ); +for (i =0 ; i < buf_size_in_dwords; i++) + buffer[i] =iwl_read_prph_no_grab (trans, +MON_DMARB_RD_DATA_ADDR ); +iwl_write_prph_no_grab (trans,MON_DMARB_RD_CTL_ADDR ,0x0 ); + +iwl_trans_release_nic_access (trans, &flags); + +return monitor_len; +} + +static u32 +iwl_trans_pcie_dump_monitor (struct iwl_trans *trans, +struct iwl_fw_error_dump_data **data, +u32 monitor_len) +{ +struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); +u32 len =0 ; + +if ((trans_pcie->fw_mon_page && + trans->cfg->device_family ==IWL_DEVICE_FAMILY_7000 ) || + trans->dbg_dest_tlv) { +struct iwl_fw_error_dump_fw_mon *fw_mon_data; +u32 base, write_ptr, wrap_cnt; + +/* If there was a dest TLV - use the values from there */ +if (trans->dbg_dest_tlv) { + write_ptr = +le32_to_cpu (trans->dbg_dest_tlv->write_ptr_reg); + wrap_cnt =le32_to_cpu (trans->dbg_dest_tlv->wrap_count); + base =le32_to_cpu (trans->dbg_dest_tlv->base_reg); + }else { + base =MON_BUFF_BASE_ADDR ; + write_ptr =MON_BUFF_WRPTR ; + wrap_cnt =MON_BUFF_CYCLE_CNT ; + } + + (*data)->type =cpu_to_le32 (IWL_FW_ERROR_DUMP_FW_MONITOR ); + fw_mon_data = (void *)(*data)->data; + fw_mon_data->fw_mon_wr_ptr = +cpu_to_le32 (iwl_read_prph (trans, write_ptr)); + fw_mon_data->fw_mon_cycle_cnt = +cpu_to_le32 (iwl_read_prph (trans, wrap_cnt)); + fw_mon_data->fw_mon_base_ptr = +cpu_to_le32 (iwl_read_prph (trans, base)); + + len +=sizeof (**data) +sizeof (*fw_mon_data); +if (trans_pcie->fw_mon_page) { +/* +* The firmware is now asserted, it won't write anything +* to the buffer. CPU can take ownership to fetch the +* data. The buffer will be handed back to the device +* before the firmware will be restarted. +*/ +dma_sync_single_for_cpu (trans->dev, + trans_pcie->fw_mon_phys, + trans_pcie->fw_mon_size, +DMA_FROM_DEVICE ); +memcpy (fw_mon_data->data, +page_address (trans_pcie->fw_mon_page), + trans_pcie->fw_mon_size); + + monitor_len = trans_pcie->fw_mon_size; + }else if (trans->dbg_dest_tlv->monitor_mode ==SMEM_MODE ) { +/* +* Update pointers to reflect actual values after +* shifting +*/ + base =iwl_read_prph (trans, base) << + trans->dbg_dest_tlv->base_shift; +iwl_trans_read_mem (trans, base, fw_mon_data->data, + monitor_len /sizeof (u32)); + }else if (trans->dbg_dest_tlv->monitor_mode ==MARBH_MODE ) { + monitor_len = +iwl_trans_pci_dump_marbh_monitor (trans, + fw_mon_data, + monitor_len); + }else { +/* Didn't match anything - output no monitor data */ + monitor_len =0 ; + } + + len += monitor_len; + (*data)->len =cpu_to_le32 (monitor_len +sizeof (*fw_mon_data)); + } + +return len; +} + +static struct iwl_trans_dump_data +*iwl_trans_pcie_dump_data (struct iwl_trans *trans, +const struct iwl_fw_dbg_trigger_tlv *trigger) {struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans);struct iwl_fw_error_dump_data *data;struct iwl_txq *cmdq = &trans_pcie->txq[trans_pcie->cmd_queue];struct iwl_fw_error_dump_txcmd *txcmd;struct iwl_trans_dump_data *dump_data; -u32 len; +u32 len, num_rbs;u32 monitor_len;int i, ptr; +bool dump_rbs =test_bit (STATUS_FW_ERROR , &trans->status);/* transport dump header */ len =sizeof (*dump_data);
@@ -2229,22 +2392,6 @@ struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans) len +=sizeof (*data) + cmdq->q.n_window * (sizeof (*txcmd) +TFD_MAX_PAYLOAD_SIZE ); -/* CSR registers */ - len +=sizeof (*data) +IWL_CSR_TO_DUMP ; - -/* PRPH registers */ -for (i =0 ; i <ARRAY_SIZE (iwl_prph_dump_addr); i++) { -/* The range includes both boundaries */ -int num_bytes_in_chunk = iwl_prph_dump_addr[i].end - - iwl_prph_dump_addr[i].start +4 ; - - len +=sizeof (*data) +sizeof (struct iwl_fw_error_dump_prph ) + - num_bytes_in_chunk; - } - -/* FH registers */ - len +=sizeof (*data) + (FH_MEM_UPPER_BOUND -FH_MEM_LOWER_BOUND ); -/* FW monitor */ if (trans_pcie->fw_mon_page) { len += sizeof(*data) + sizeof(struct iwl_fw_error_dump_fw_mon) +
@@ -2262,7 +2409,8 @@ struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans) trans->dbg_dest_tlv->end_shift;/* Make "end" point to the actual end */ -if (trans->cfg->device_family ==IWL_DEVICE_FAMILY_8000 ) +if (trans->cfg->device_family ==IWL_DEVICE_FAMILY_8000 || + trans->dbg_dest_tlv->monitor_mode ==MARBH_MODE ) end += (1 << trans->dbg_dest_tlv->end_shift); monitor_len = end - base; len += sizeof(*data) + sizeof(struct iwl_fw_error_dump_fw_mon) +
@@ -2271,6 +2419,35 @@ struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans) monitor_len =0 ; } +if (trigger && (trigger->mode &IWL_FW_DBG_TRIGGER_MONITOR_ONLY )) { + dump_data =vzalloc (len); +if (!dump_data) +return NULL ; + + data = (void *)dump_data->data; + len =iwl_trans_pcie_dump_monitor (trans, &data, monitor_len); + dump_data->len = len; + +return dump_data; + } + +/* CSR registers */ + len +=sizeof (*data) +IWL_CSR_TO_DUMP ; + +/* FH registers */ + len +=sizeof (*data) + (FH_MEM_UPPER_BOUND -FH_MEM_LOWER_BOUND ); + +if (dump_rbs) { +/* RBs */ + num_rbs =le16_to_cpu (ACCESS_ONCE ( + trans_pcie->rxq.rb_stts->closed_rb_num)) + &0x0FFF ; + num_rbs = (num_rbs - trans_pcie->rxq.read) &RX_QUEUE_MASK ; + len += num_rbs * (sizeof (*data) + +sizeof (struct iwl_fw_error_dump_rb ) + + (PAGE_SIZE << trans_pcie->rx_page_order)); + } + dump_data =vzalloc (len);if (!dump_data)return NULL ;
@@ -2304,74 +2481,12 @@ struct iwl_trans_dump_data *iwl_trans_pcie_dump_data(struct iwl_trans *trans) len +=sizeof (*data); data =iwl_fw_error_next_data (data); - len +=iwl_trans_pcie_dump_prph (trans, &data); len +=iwl_trans_pcie_dump_csr (trans, &data); len +=iwl_trans_pcie_fh_regs_dump (trans, &data); -/* data is already pointing to the next section */ - -if ((trans_pcie->fw_mon_page && - trans->cfg->device_family ==IWL_DEVICE_FAMILY_7000 ) || - trans->dbg_dest_tlv) { -struct iwl_fw_error_dump_fw_mon *fw_mon_data; -u32 base, write_ptr, wrap_cnt; - -/* If there was a dest TLV - use the values from there */ -if (trans->dbg_dest_tlv) { - write_ptr = -le32_to_cpu (trans->dbg_dest_tlv->write_ptr_reg); - wrap_cnt =le32_to_cpu (trans->dbg_dest_tlv->wrap_count); - base =le32_to_cpu (trans->dbg_dest_tlv->base_reg); - }else { - base =MON_BUFF_BASE_ADDR ; - write_ptr =MON_BUFF_WRPTR ; - wrap_cnt =MON_BUFF_CYCLE_CNT ; - } - - data->type =cpu_to_le32 (IWL_FW_ERROR_DUMP_FW_MONITOR ); - fw_mon_data = (void *)data->data; - fw_mon_data->fw_mon_wr_ptr = -cpu_to_le32 (iwl_read_prph (trans, write_ptr)); - fw_mon_data->fw_mon_cycle_cnt = -cpu_to_le32 (iwl_read_prph (trans, wrap_cnt)); - fw_mon_data->fw_mon_base_ptr = -cpu_to_le32 (iwl_read_prph (trans, base)); +if (dump_rbs) + len +=iwl_trans_pcie_dump_rbs (trans, &data, num_rbs); - len +=sizeof (*data) +sizeof (*fw_mon_data); -if (trans_pcie->fw_mon_page) { - data->len =cpu_to_le32 (trans_pcie->fw_mon_size + -sizeof (*fw_mon_data)); - -/* -* The firmware is now asserted, it won't write anything -* to the buffer. CPU can take ownership to fetch the -* data. The buffer will be handed back to the device -* before the firmware will be restarted. -*/ -dma_sync_single_for_cpu (trans->dev, - trans_pcie->fw_mon_phys, - trans_pcie->fw_mon_size, -DMA_FROM_DEVICE ); -memcpy (fw_mon_data->data, -page_address (trans_pcie->fw_mon_page), - trans_pcie->fw_mon_size); - - len += trans_pcie->fw_mon_size; - }else { -/* If we are here then the buffer is internal */ - -/* -* Update pointers to reflect actual values after -* shifting -*/ - base =iwl_read_prph (trans, base) << - trans->dbg_dest_tlv->base_shift; -iwl_trans_read_mem (trans, base, fw_mon_data->data, - monitor_len /sizeof (u32)); - data->len =cpu_to_le32 (sizeof (*fw_mon_data) + - monitor_len); - len += monitor_len; - } - } + len +=iwl_trans_pcie_dump_monitor (trans, &data, monitor_len); dump_data->len = len;
@@ -2396,10 +2511,9 @@ static const struct iwl_trans_ops trans_ops_pcie = { .txq_disable = iwl_trans_pcie_txq_disable, .txq_enable = iwl_trans_pcie_txq_enable, - .dbgfs_register = iwl_trans_pcie_dbgfs_register, - .wait_tx_queue_empty = iwl_trans_pcie_wait_txq_empty, .freeze_txq_timer = iwl_trans_pcie_freeze_txq_timer, + .block_txq_ptrs = iwl_trans_pcie_block_txq_ptrs, .write8 = iwl_trans_pcie_write8, .write32 = iwl_trans_pcie_write32,
@@ -2427,28 +2541,31 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,struct iwl_trans_pcie *trans_pcie;struct iwl_trans *trans;u16 pci_cmd; -int err; +int ret; - trans =kzalloc (sizeof (struct iwl_trans ) + -sizeof (struct iwl_trans_pcie ),GFP_KERNEL ); -if (!trans) { - err = -ENOMEM ; - goto out; - } + trans =iwl_trans_alloc (sizeof (struct iwl_trans_pcie ), + &pdev->dev, cfg, &trans_ops_pcie,0 ); +if (!trans) +return ERR_PTR (-ENOMEM ); + + trans->max_skb_frags =IWL_PCIE_MAX_FRAGS ; trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); - trans->ops = &trans_ops_pcie; - trans->cfg = cfg; -trans_lockdep_init (trans); trans_pcie->trans = trans;spin_lock_init (&trans_pcie->irq_lock);spin_lock_init (&trans_pcie->reg_lock);spin_lock_init (&trans_pcie->ref_lock); +mutex_init (&trans_pcie->mutex);init_waitqueue_head (&trans_pcie->ucode_write_waitq); + trans_pcie->tso_hdr_page = alloc_percpu(struct iwl_tso_hdr_page); +if (!trans_pcie->tso_hdr_page) { + ret = -ENOMEM ; + goto out_no_pci; + } - err =pci_enable_device (pdev); -if (err) + ret =pci_enable_device (pdev); +if (ret) goto out_no_pci;if (!cfg->base_params->pcie_l1_allowed) {
@@ -2464,23 +2581,23 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,pci_set_master (pdev); - err =pci_set_dma_mask (pdev,DMA_BIT_MASK (36 )); -if (!err) - err =pci_set_consistent_dma_mask (pdev,DMA_BIT_MASK (36 )); -if (err) { - err =pci_set_dma_mask (pdev,DMA_BIT_MASK (32 )); -if (!err) - err =pci_set_consistent_dma_mask (pdev, + ret =pci_set_dma_mask (pdev,DMA_BIT_MASK (36 )); +if (!ret) + ret =pci_set_consistent_dma_mask (pdev,DMA_BIT_MASK (36 )); +if (ret) { + ret =pci_set_dma_mask (pdev,DMA_BIT_MASK (32 )); +if (!ret) + ret =pci_set_consistent_dma_mask (pdev,DMA_BIT_MASK (32 ));/* both attempts failed: */ -if (err) { +if (ret) {dev_err (&pdev->dev,"No suitable DMA available\n" ); goto out_pci_disable_device; } } - err =pci_request_regions (pdev,DRV_NAME ); -if (err) { + ret =pci_request_regions (pdev,DRV_NAME ); +if (ret) {dev_err (&pdev->dev,"pci_request_regions failed\n" ); goto out_pci_disable_device; }
@@ -2488,7 +2605,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, trans_pcie->hw_base =pci_ioremap_bar (pdev,0 );if (!trans_pcie->hw_base) {dev_err (&pdev->dev,"pci_ioremap_bar failed\n" ); - err = -ENODEV ; + ret = -ENODEV ; goto out_pci_release_regions; }
@@ -2500,9 +2617,9 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, trans_pcie->pci_dev = pdev;iwl_disable_interrupts (trans); - err =pci_enable_msi (pdev); -if (err) { -dev_err (&pdev->dev,"pci_enable_msi failed(0X%x)\n" , err); + ret =pci_enable_msi (pdev); +if (ret) { +dev_err (&pdev->dev,"pci_enable_msi failed(0X%x)\n" , ret);/* enable rfkill interrupt: hw bug w/a */ pci_read_config_word (pdev,PCI_COMMAND , &pci_cmd);if (pci_cmd &PCI_COMMAND_INTX_DISABLE ) {
@@ -2520,7 +2637,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,*/ if (trans->cfg->device_family ==IWL_DEVICE_FAMILY_8000 ) {unsigned long flags; -int ret; trans->hw_rev = (trans->hw_rev &0xfff0 ) | (CSR_HW_REV_STEP (trans->hw_rev <<2 ) <<2 );
@@ -2548,13 +2664,13 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, goto out_pci_disable_msi; } -if (iwl_trans_grab_nic_access (trans, false, &flags)) { +if (iwl_trans_grab_nic_access (trans, &flags)) {u32 hw_step; - hw_step =__iwl_read_prph (trans,WFPM_CTRL_REG ); + hw_step =iwl_read_prph_no_grab (trans,WFPM_CTRL_REG ); hw_step |=ENABLE_WFPM ; -__iwl_write_prph (trans,WFPM_CTRL_REG , hw_step); - hw_step =__iwl_read_prph (trans,AUX_MISC_REG ); +iwl_write_prph_no_grab (trans,WFPM_CTRL_REG , hw_step); + hw_step =iwl_read_prph_no_grab (trans,AUX_MISC_REG ); hw_step = (hw_step >>HW_STEP_LOCATION_BITS ) &0xF ;if (hw_step ==0x3 ) trans->hw_rev = (trans->hw_rev & 0xFFFFFFF3) |
@@ -2570,43 +2686,24 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,/* Initialize the wait queue for commands */ init_waitqueue_head (&trans_pcie->wait_command_queue); -snprintf (trans->dev_cmd_pool_name,sizeof (trans->dev_cmd_pool_name), -"iwl_cmd_pool:%s" ,dev_name (trans->dev)); - - trans->dev_cmd_headroom =0 ; - trans->dev_cmd_pool = -kmem_cache_create (trans->dev_cmd_pool_name, -sizeof (struct iwl_device_cmd ) - + trans->dev_cmd_headroom, -sizeof (void *), -SLAB_HWCACHE_ALIGN , -NULL ); - -if (!trans->dev_cmd_pool) { - err = -ENOMEM ; + ret =iwl_pcie_alloc_ict (trans); +if (ret) goto out_pci_disable_msi; - } -if (iwl_pcie_alloc_ict (trans)) - goto out_free_cmd_pool; - - err =request_threaded_irq (pdev->irq, iwl_pcie_isr, + ret =request_threaded_irq (pdev->irq, iwl_pcie_isr, iwl_pcie_irq_handler,IRQF_SHARED ,DRV_NAME , trans); -if (err) { +if (ret) {IWL_ERR (trans,"Error allocating IRQ %d\n" , pdev->irq); goto out_free_ict; } trans_pcie->inta_mask =CSR_INI_SET_MASK ; - trans->d0i3_mode =IWL_D0I3_MODE_ON_SUSPEND ;return trans; out_free_ict:iwl_pcie_free_ict (trans); -out_free_cmd_pool: -kmem_cache_destroy (trans->dev_cmd_pool); out_pci_disable_msi:pci_disable_msi (pdev); out_pci_release_regions:
@@ -2614,7 +2711,7 @@ out_pci_release_regions: out_pci_disable_device:pci_disable_device (pdev); out_no_pci: -kfree (trans); -out: -return ERR_PTR (err); +free_percpu (trans_pcie->tso_hdr_page); +iwl_trans_free (trans); +return ERR_PTR (ret); }
drivers/net/wireless/iwlwifi/pcie/trans.c +12 -3
@@ -7,6 +7,7 @@* * Copyright(c) 2007 - 2015 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH +* Copyright(c) 2016 Intel Deutschland GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as
@@ -33,6 +34,7 @@* * Copyright(c) 2005 - 2015 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH +* Copyright(c) 2016 Intel Deutschland GmbH * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -881,9 +883,16 @@ static void iwl_pcie_apply_destination(struct iwl_trans *trans)if (dest->monitor_mode ==EXTERNAL_MODE && trans_pcie->fw_mon_size) {iwl_write_prph (trans,le32_to_cpu (dest->base_reg), trans_pcie->fw_mon_phys >> dest->base_shift); -iwl_write_prph (trans,le32_to_cpu (dest->end_reg), - (trans_pcie->fw_mon_phys + - trans_pcie->fw_mon_size) >> dest->end_shift); +if (trans->cfg->device_family ==IWL_DEVICE_FAMILY_8000 ) +iwl_write_prph (trans,le32_to_cpu (dest->end_reg), + (trans_pcie->fw_mon_phys + + trans_pcie->fw_mon_size -256 ) >> + dest->end_shift); +else +iwl_write_prph (trans,le32_to_cpu (dest->end_reg), + (trans_pcie->fw_mon_phys + + trans_pcie->fw_mon_size) >> + dest->end_shift); } }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] btrfs: handle invalid num_stripes in sys_array
In reply to Sasha LevinFrom: David Sterba <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f5cdedd73fa71b74dcc42f2a11a5735d89ce7c4f ]
We can handle the special case of num_stripes == 0 directly inside btrfs_read_sys_array. The BUG_ON in btrfs_chunk_item_size is there to catch other unhandled cases where we fail to validate external data.
A crafted or corrupted image crashes at mount time:
BTRFS: device fsid 9006933e-2a9a-44f0-917f-514252aeec2c devid 1 transid 7 /dev/loop0 BTRFS info (device loop0): disk space caching is enabled
BUG: failure at fs/btrfs/ctree.h:337/btrfs_chunk_item_size()! Kernel panic - not syncing: BUG! CPU: 0 PID: 313 Comm: mount Not tainted 4.2.5-00657-ge047887-dirty #25 Stack: 637af890 60062489 602aeb2e 604192ba 60387961 00000011 637af8a0 6038a835 637af9c0 6038776b 634ef32b 00000000 Call Trace: [<6001c86d>] show_stack+0xfe/0x15b [<6038a835>] dump_stack+0x2a/0x2c [<6038776b>] panic+0x13e/0x2b3 [<6020f099>] btrfs_read_sys_array+0x25d/0x2ff [<601cfbbe>] open_ctree+0x192d/0x27af [<6019c2c1>] btrfs_mount+0x8f5/0xb9a [<600bc9a7>] mount_fs+0x11/0xf3 [<600d5167>] vfs_kern_mount+0x75/0x11a [<6019bcb0>] btrfs_mount+0x2e4/0xb9a [<600bc9a7>] mount_fs+0x11/0xf3 [<600d5167>] vfs_kern_mount+0x75/0x11a [<600d710b>] do_mount+0xa35/0xbc9 [<600d7557>] SyS_mount+0x95/0xc8 [<6001e884>] handle_syscall+0x6b/0x8e
--- fs/btrfs/volumes.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/btrfs/volumes.c +8 -0
@@ -6322,6 +6322,14 @@ int btrfs_read_sys_array(struct btrfs_root *root) goto out_short_read; num_stripes =btrfs_chunk_num_stripes (sb, chunk); +if (!num_stripes) { +printk (KERN_ERR +"BTRFS: invalid number of stripes %u in sys_array at offset %u\n" , + num_stripes, cur_offset); + ret = -EIO ; +break ; + } + len =btrfs_chunk_item_size (num_stripes);if (cur_offset + len > array_size) goto out_short_read;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] locks: fix unlock when fcntl_setlk races with a close
In reply to Sasha LevinFrom: Jeff Layton <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7f3697e24dc3820b10f445a4a7d914fc356012d1 ]
Dmitry reported that he was able to reproduce the WARN_ON_ONCE that fires in locks_free_lock_context when the flc_posix list isn't empty.
The problem turns out to be that we're basically rebuilding the file_lock from scratch in fcntl_setlk when we discover that the setlk has raced with a close. If the l_whence field is SEEK_CUR or SEEK_END, then we may end up with fl_start and fl_end values that differ from when the lock was initially set, if the file position or length of the file has changed in the interim.
Fix this by just reusing the same lock request structure, and simply override fl_type value with F_UNLCK as appropriate. That ensures that we really are unlocking the lock that was initially set.
While we're there, make sure that we do pop a WARN_ON_ONCE if the removal ever fails. Also return -EBADF in this event, since that's what we would have returned if the close had happened earlier.
--- fs/locks.c | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-)
fs/locks.c +30 -21
@@ -2154,7 +2154,6 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, goto out; } -again: error =flock_to_posix_lock (filp, file_lock, &flock);if (error) goto out;
@@ -2196,19 +2195,22 @@ again:* Attempt to detect a close/fcntl race and recover by * releasing the lock that was just acquired. */ -/* -* we need that spin_lock here - it prevents reordering between -* update of i_flctx->flc_posix and check for it done in close(). -* rcu_read_lock() wouldn't do. -*/ -spin_lock (¤t->files->file_lock); - f =fcheck (fd); -spin_unlock (¤t->files->file_lock); -if (!error && f != filp && flock.l_type !=F_UNLCK ) { - flock.l_type =F_UNLCK ; - goto again; +if (!error && file_lock->fl_type !=F_UNLCK ) { +/* +* We need that spin_lock here - it prevents reordering between +* update of i_flctx->flc_posix and check for it done in +* close(). rcu_read_lock() wouldn't do. +*/ +spin_lock (¤t->files->file_lock); + f =fcheck (fd); +spin_unlock (¤t->files->file_lock); +if (f != filp) { + file_lock->fl_type =F_UNLCK ; + error =do_lock_file_wait (filp, cmd, file_lock); +WARN_ON_ONCE (error); + error = -EBADF ; + } } - out:locks_free_lock (file_lock);return error;
@@ -2294,7 +2296,6 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd, goto out; } -again: error =flock64_to_posix_lock (filp, file_lock, &flock);if (error) goto out;
@@ -2336,14 +2337,22 @@ again:* Attempt to detect a close/fcntl race and recover by * releasing the lock that was just acquired. */ -spin_lock (¤t->files->file_lock); - f =fcheck (fd); -spin_unlock (¤t->files->file_lock); -if (!error && f != filp && flock.l_type !=F_UNLCK ) { - flock.l_type =F_UNLCK ; - goto again; +if (!error && file_lock->fl_type !=F_UNLCK ) { +/* +* We need that spin_lock here - it prevents reordering between +* update of i_flctx->flc_posix and check for it done in +* close(). rcu_read_lock() wouldn't do. +*/ +spin_lock (¤t->files->file_lock); + f =fcheck (fd); +spin_unlock (¤t->files->file_lock); +if (f != filp) { + file_lock->fl_type =F_UNLCK ; + error =do_lock_file_wait (filp, cmd, file_lock); +WARN_ON_ONCE (error); + error = -EBADF ; + } } - out:locks_free_lock (file_lock);return error;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] PCI: Fix minimum allocation address overwrite
In reply to Sasha LevinFrom: Christoph Biedl <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 3460baa620685c20f5ee19afb6d99d26150c382c ]
Commit 36e097a8a297 ("PCI: Split out bridge window override of minimum allocation address") claimed to do no functional changes but unfortunately
did: The "min" variable is altered. At least the AVM A1 PCMCIA adapter was no longer detected, breaking ISDN operation.
Use a local copy of "min" to restore the previous behaviour.
--- drivers/pci/bus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/bus.c +4 -2
@@ -140,6 +140,8 @@ static int pci_bus_alloc_from_region(struct pci_bus *bus, struct resource *res, type_mask |=IORESOURCE_TYPE_BITS ;pci_bus_for_each_resource (bus, r, i) { +resource_size_t min_used = min; +if (!r)continue ;
@@ -163,12 +165,12 @@ static int pci_bus_alloc_from_region(struct pci_bus *bus, struct resource *res,* overrides "min". */ if (avail.start) - min = avail.start; + min_used = avail.start; max = avail.end;/* Ok, try it out.. */ - ret =allocate_resource (r, res, size, min, max, + ret =allocate_resource (r, res, size, min_used, max, align, alignf, alignf_data);if (ret ==0 )return 0 ;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] rtlwifi: rtl8192de: Fix incorrect module parameter descriptions
In reply to Sasha LevinFrom: Larry Finger <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d4d60b4caaa5926e1b243070770968f05656107a ]
Two of the module parameters are listed with incorrect default values.
--- drivers/net/wireless/rtlwifi/rtl8192de/sw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/rtlwifi/rtl8192de/sw.c +2 -2
@@ -376,8 +376,8 @@ module_param_named(swlps, rtl92de_mod_params.swctrl_lps, bool, 0444);module_param_named (fwlps, rtl92de_mod_params.fwctrl_lps, bool,0444 );MODULE_PARM_DESC (swenc,"Set to 1 for software crypto (default 0)\n" );MODULE_PARM_DESC (ips,"Set to 0 to not use link power save (default 1)\n" ); -MODULE_PARM_DESC (swlps,"Set to 1 to use SW control power save (default 0)\n" ); -MODULE_PARM_DESC (fwlps,"Set to 1 to use FW control power save (default 1)\n" ); +MODULE_PARM_DESC (swlps,"Set to 1 to use SW control power save (default 1)\n" ); +MODULE_PARM_DESC (fwlps,"Set to 1 to use FW control power save (default 0)\n" );MODULE_PARM_DESC (debug,"Set debug level (0-5) (default 0)" ); static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] bcache: allows use of register in udev to avoid "device_busy" error.
In reply to Sasha LevinFrom: Gabriel de Perthuis <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d7076f21629f8f329bca4a44dc408d94670f49e2 ]
Allows to use register, not register_quiet in udev to avoid "device_busy" error. The initial patch proposed at https://lkml.org/lkml/2013/8/26/549 by Gabriel de Perthuis <[email protected]> does not unlock the mutex and hangs the kernel.
See http://thread.gmane.org/gmane.linux.kernel.bcache.devel/2594 for the discussion.
--- drivers/md/bcache/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/md/bcache/super.c +3 -2
@@ -1972,6 +1972,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,else err ="device busy" ;mutex_unlock (&bch_register_lock); +if (attr == &ksysfs_register_quiet) + goto out; } goto err; }
@@ -2010,8 +2012,7 @@ out: err_close:blkdev_put (bdev,FMODE_READ |FMODE_WRITE |FMODE_EXCL ); err: -if (attr != &ksysfs_register_quiet) -pr_info ("error opening %s: %s" , path, err); +pr_info ("error opening %s: %s" , path, err); ret = -EINVAL ; goto out; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] scsi: add Synology to 1024 sector blacklist
In reply to Sasha LevinFrom: Mike Christie <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9055082fb100cc66e20c048251d05159f5f2cfba ]
Another iscsi target that cannot handle large IOs, but does not tell us a limit.
The Synology iSCSI targets report:
Block limits VPD page (SBC):
Write same no zero (WSNZ): 0
Maximum compare and write length: 0 blocks
Optimal transfer length granularity: 0 blocks
Maximum transfer length: 0 blocks
Optimal transfer length: 0 blocks
Maximum prefetch length: 0 blocks
Maximum unmap LBA count: 0
Maximum unmap block descriptor count: 0
Optimal unmap granularity: 0
Unmap granularity alignment valid: 0
Unmap granularity alignment: 0
Maximum write same length: 0x0 blocks
and the size of the command it can handle seems to depend on how much memory it can allocate at the time. This results in IO errors when handling large IOs. This patch just has us use the old 1024 default sectors for this target by adding it to the scsi blacklist. We do not have good contacs with this vendors, so I have not been able to try and fix on their side.
I have posted this a long while back, but it was not merged. This version just fixes it up for merge/patch failures in the original version.
--- drivers/scsi/scsi_devinfo.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/scsi_devinfo.c +1 -0
@@ -227,6 +227,7 @@ static struct { {"Promise", "VTrak E610f", NULL, BLIST_SPARSELUN | BLIST_NO_RSOC}, {"Promise", "", NULL, BLIST_SPARSELUN}, {"QNAP", "iSCSI Storage", NULL, BLIST_MAX_1024}, + {"SYNOLOGY", "iSCSI Storage", NULL, BLIST_MAX_1024}, {"QUANTUM", "XP34301", "1071", BLIST_NOTQ}, {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN}, {"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN},
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] dm snapshot: fix hung bios when copy error occurs
In reply to Sasha LevinFrom: Mikulas Patocka <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 385277bfb57faac44e92497104ba542cdd82d5fe ]
When there is an error copying a chunk dm-snapshot can incorrectly hold associated bios indefinitely, resulting in hung IO.
The function copy_callback sets pe->error if there was error copying the chunk, and then calls complete_exception. complete_exception calls pending_complete on error, otherwise it calls commit_exception with commit_callback (and commit_callback calls complete_exception).
The persistent exception store (dm-snap-persistent.c) assumes that calls to prepare_exception and commit_exception are paired. persistent_prepare_exception increases ps->pending_count and persistent_commit_exception decreases it.
If there is a copy error, persistent_prepare_exception is called but persistent_commit_exception is not. This results in the variable ps->pending_count never returning to zero and that causes some pending exceptions (and their associated bios) to be held forever.
Fix this by unconditionally calling commit_exception regardless of whether the copy was successful. A new "valid" parameter is added to commit_exception -- when the copy fails this parameter is set to zero so that the chunk that failed to copy (and all following chunks) is not recorded in the snapshot store. Also, remove commit_callback now that it is merely a wrapper around pending_complete.
--- drivers/md/dm-exception-store.h | 2 +- drivers/md/dm-snap-persistent.c | 5 ++++- drivers/md/dm-snap-transient.c | 4 ++-- drivers/md/dm-snap.c | 20 +++++--------------- 4 files changed, 12 insertions(+), 19 deletions(-)
drivers/md/dm-exception-store.h +1 -1
@@ -70,7 +70,7 @@ struct dm_exception_store_type {* Update the metadata with this exception. */ void (*commit_exception) (struct dm_exception_store *store, -struct dm_exception *e, +struct dm_exception *e,int valid,void (*callback) (void *,int success),void *callback_context);
drivers/md/dm-snap-persistent.c +4 -1
@@ -694,7 +694,7 @@ static int persistent_prepare_exception(struct dm_exception_store *store, }static void persistent_commit_exception (struct dm_exception_store *store, -struct dm_exception *e, +struct dm_exception *e,int valid,void (*callback) (void *,int success),void *callback_context) {
@@ -703,6 +703,9 @@ static void persistent_commit_exception(struct dm_exception_store *store,struct core_exception ce;struct commit_callback *cb; +if (!valid) + ps->valid =0 ; + ce.old_chunk = e->old_chunk; ce.new_chunk = e->new_chunk;write_exception (ps, ps->current_committed++, &ce);
drivers/md/dm-snap-transient.c +2 -2
@@ -52,12 +52,12 @@ static int transient_prepare_exception(struct dm_exception_store *store, }static void transient_commit_exception (struct dm_exception_store *store, -struct dm_exception *e, +struct dm_exception *e,int valid,void (*callback) (void *,int success),void *callback_context) {/* Just succeed */ -callback (callback_context,1 ); +callback (callback_context, valid); } static void transient_usage(struct dm_exception_store *store,
drivers/md/dm-snap.c +5 -15
@@ -1428,8 +1428,9 @@ static void __invalidate_snapshot(struct dm_snapshot *s, int err)dm_table_event (s->ti->table); } -static void pending_complete (struct dm_snap_pending_exception *pe,int success) +static void pending_complete (void *context,int success) { +struct dm_snap_pending_exception *pe = context;struct dm_exception *e;struct dm_snapshot *s = pe->snap;struct bio *origin_bios =NULL ;
@@ -1500,24 +1501,13 @@ out:free_pending_exception (pe); } -static void commit_callback (void *context,int success) -{ -struct dm_snap_pending_exception *pe = context; - -pending_complete (pe, success); -} -static void complete_exception (struct dm_snap_pending_exception *pe) {struct dm_snapshot *s = pe->snap; -if (unlikely (pe->copy_error)) -pending_complete (pe,0 ); - -else -/* Update the metadata if we are persistent */ - s->store->type->commit_exception (s->store, &pe->e, - commit_callback, pe); +/* Update the metadata if we are persistent */ + s->store->type->commit_exception (s->store, &pe->e, !pe->copy_error, + pending_complete, pe); }/*
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] uml: flush stdout before forking
In reply to Sasha LevinFrom: Vegard Nossum <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0754fb298f2f2719f0393491d010d46cfb25d043 ]
I was seeing some really weird behaviour where piping UML's output somewhere would cause output to get duplicated:
$ ./vmlinux | head -n 40
Checking that ptrace can change system call numbers...Core dump limits :
soft - 0
hard - NONE
OK
Checking syscall emulation patch for ptrace...Core dump limits :
soft - 0
hard - NONE
OK
Checking advanced syscall emulation patch for ptrace...Core dump limits :
soft - 0
hard - NONE
OK
Core dump limits :
soft - 0
hard - NONEThis is because these tests do a fork() which duplicates the non-empty stdout buffer, then glibc flushes the duplicated buffer as each child exits.
A simple workaround is to flush before forking.
--- arch/um/os-Linux/start_up.c | 2 ++ 1 file changed, 2 insertions(+)
arch/um/os-Linux/start_up.c +2 -0
@@ -94,6 +94,8 @@ static int start_ptraced_child(void) {int pid, n, status; +fflush (stdout); + pid =fork ();if (pid ==0 )ptrace_child ();
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] drm/nouveau/kms: take mode_config mutex in connector hotplug path
In reply to Sasha LevinFrom: Ben Skeggs <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0a882cadbc63fd2da3994af7115b4ada2fcbd638 ]
fdo#93634
--- drivers/gpu/drm/nouveau/nouveau_connector.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/nouveau/nouveau_connector.c +3 -0
@@ -969,10 +969,13 @@ nouveau_connector_hotplug(struct nvif_notify *notify)NV_DEBUG (drm,"%splugged %s\n" , plugged ?"" :"un" , name); +mutex_lock (&drm->dev->mode_config.mutex);if (plugged)drm_helper_connector_dpms (connector,DRM_MODE_DPMS_ON );else drm_helper_connector_dpms (connector,DRM_MODE_DPMS_OFF ); +mutex_unlock (&drm->dev->mode_config.mutex); +drm_helper_hpd_irq_event (connector->dev); }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] uml: fix hostfs mknod()
In reply to Sasha LevinFrom: Vegard Nossum <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9f2dfda2f2f1c6181c3732c16b85c59ab2d195e0 ]
An inverted return value check in hostfs_mknod() caused the function to return success after handling it as an error (and cleaning up).
It resulted in the following segfault when trying to bind() a named unix socket:
Pid: 198, comm: a.out Not tainted 4.4.0-rc4
RIP: 0033:[<0000000061077df6>] RSP: 00000000daae5d60 EFLAGS: 00010202 RAX: 0000000000000000 RBX: 000000006092a460 RCX: 00000000dfc54208 RDX: 0000000061073ef1 RSI: 0000000000000070 RDI: 00000000e027d600 RBP: 00000000daae5de0 R08: 00000000da980ac0 R09: 0000000000000000 R10: 0000000000000003 R11: 00007fb1ae08f72a R12: 0000000000000000 R13: 000000006092a460 R14: 00000000daaa97c0 R15: 00000000daaa9a88 Kernel panic - not syncing: Kernel mode fault at addr 0x40, ip 0x61077df6 CPU: 0 PID: 198 Comm: a.out Not tainted 4.4.0-rc4 #1 Stack: e027d620 dfc54208 0000006f da981398 61bee000 0000c1ed daae5de0 0000006e e027d620 dfcd4208 00000005 6092a460 Call Trace: [<60dedc67>] SyS_bind+0xf7/0x110 [<600587be>] handle_syscall+0x7e/0x80 [<60066ad7>] userspace+0x3e7/0x4e0 [<6006321f>] ? save_registers+0x1f/0x40 [<6006c88e>] ? arch_prctl+0x1be/0x1f0 [<60054985>] fork_handler+0x85/0x90
Let's also get rid of the "cosmic ray protection" while we're at it.
--- fs/hostfs/hostfs_kern.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/hostfs/hostfs_kern.c +1 -3
@@ -730,15 +730,13 @@ static int hostfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,init_special_inode (inode, mode, dev); err =do_mknod (name, mode,MAJOR (dev),MINOR (dev)); -if (!err) +if (err) goto out_free; err =read_name (inode, name);__putname (name);if (err) goto out_put; -if (err) - goto out_put;d_instantiate (dentry, inode);return 0 ;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] xfs: inode recovery readahead can race with inode buffer creation
In reply to Sasha LevinFrom: Dave Chinner <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b79f4a1c68bb99152d0785ee4ea3ab4396cdacc6 ]
When we do inode readahead in log recovery, we do can do the readahead before we've replayed the icreate transaction that stamps the buffer with inode cores. The inode readahead verifier catches this and marks the buffer as !done to indicate that it doesn't yet contain valid inodes.
In adding buffer error notification (i.e. setting b_error = -EIO at the same time as as we clear the done flag) to such a readahead verifier failure, we can then get subsequent inode recovery failing with this error:
XFS (dm-0): metadata I/O error: block 0xa00060 ("xlog_recover_do..(read#2)") error 5 numblks 32
This occurs when readahead completion races with icreate item replay such as:
inode readahead
find buffer
lock buffer
submit RA io
....
icreate recovery
xfs_trans_get_buffer
find buffer
lock buffer
<blocks on RA completion>
.....
<ra completion>
fails verifier
clear XBF_DONE
set bp->b_error = -EIO
release and unlock buffer
<icreate gains lock>
icreate initialises buffer
marks buffer as done
adds buffer to delayed write queue
releases buffer
At this point, we have an initialised inode buffer that is up to date but has an -EIO state registered against it. When we finally get to recovering an inode in that buffer:
inode item recovery
xfs_trans_read_buffer
find buffer
lock buffer
sees XBF_DONE is set, returns buffer
sees bp->b_error is set
fail log recovery!
Essentially, we need xfs_trans_get_buf_map() to clear the error status of the buffer when doing a lookup. This function returns uninitialised buffers, so the buffer returned can not be in an error state and none of the code that uses this function expects b_error to be set on return. Indeed, there is an ASSERT(!bp->b_error); in the transaction case in xfs_trans_get_buf_map() that would have caught this if log recovery used transactions....
This patch firstly changes the inode readahead failure to set -EIO on the buffer, and secondly changes xfs_buf_get_map() to never return a buffer with an error state set so this first change doesn't cause unexpected log recovery failures.
--- fs/xfs/libxfs/xfs_inode_buf.c | 12 +++++++----- fs/xfs/xfs_buf.c | 7 +++++++ 2 files changed, 14 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_inode_buf.c +7 -5
@@ -63,11 +63,12 @@ xfs_inobp_check(* has not had the inode cores stamped into it. Hence for readahead, the buffer * may be potentially invalid. * -* If the readahead buffer is invalid, we don't want to mark it with an error, -* but we do want to clear the DONE status of the buffer so that a followup read -* will re-read it from disk. This will ensure that we don't get an unnecessary -* warnings during log recovery and we don't get unnecssary panics on debug -* kernels. +* If the readahead buffer is invalid, we need to mark it with an error and +* clear the DONE status of the buffer so that a followup read will re-read it +* from disk. We don't report the error otherwise to avoid warnings during log +* recovery and we don't get unnecssary panics on debug kernels. We use EIO here +* because all we want to do is say readahead failed; there is no-one to report +* the error to, so this will distinguish it from a non-ra verifier failure. */ static void xfs_inode_buf_verify(
@@ -95,6 +96,7 @@ xfs_inode_buf_verify( XFS_RANDOM_ITOBP_INOTOBP))) {if (readahead) { bp->b_flags &= ~XBF_DONE ; +xfs_buf_ioerror (bp, -EIO );return ; }
fs/xfs/xfs_buf.c +7 -0
@@ -605,6 +605,13 @@ found: } } +/* +* Clear b_error if this is a lookup from a caller that doesn't expect +* valid data to be found in the buffer. +*/ +if (!(flags &XBF_READ )) +xfs_buf_ioerror (bp,0 ); +XFS_STATS_INC (xb_get);trace_xfs_buf_get (bp, flags, _RET_IP_);return bp;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] Input: elantech - mark protocols v2 and v3 as semi-mt
In reply to Sasha LevinFrom: Benjamin Tissoires <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6544a1df11c48c8413071aac3316792e4678fbfb ]
When using a protocol v2 or v3 hardware, elantech uses the function elantech_report_semi_mt_data() to report data. This devices are rather creepy because if num_finger is 3, (x2,y2) is (0,0). Yes, only one valid touch is reported.
Anyway, userspace (libinput) is now confused by these (0,0) touches, and detect them as palm, and rejects them.
Commit 3c0213d17a09 ("Input: elantech - fix semi-mt protocol for v3 HW") was sufficient enough for xf86-input-synaptics and libinput before it has palm rejection. Now we need to actually tell libinput that this device is a semi-mt one and it should not rely on the actual values of the 2 touches.
--- drivers/input/mouse/elantech.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/elantech.c +1 -1
@@ -1214,7 +1214,7 @@ static int elantech_set_input_params(struct psmouse *psmouse)input_set_abs_params (dev,ABS_TOOL_WIDTH ,ETP_WMIN_V2 ,ETP_WMAX_V2 ,0 ,0 ); } -input_mt_init_slots (dev,2 ,0 ); +input_mt_init_slots (dev,2 ,INPUT_MT_SEMI_MT );input_set_abs_params (dev,ABS_MT_POSITION_X , x_min, x_max,0 ,0 );input_set_abs_params (dev,ABS_MT_POSITION_Y , y_min, y_max,0 ,0 );break ;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] s390: fix normalization bug in exception table sorting
In reply to Sasha LevinFrom: Ard Biesheuvel <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bcb7825a77f41c7dd91da6f7ac10b928156a322e ]
The normalization pass in the sorting routine of the relative exception table serves two purposes:
- it ensures that the address fields of the exception table entries are fully ordered, so that no ambiguities arise between entries with identical instruction offsets (i.e., when two instructions that are exactly 8 bytes apart each have an exception table entry associated with them)
- it ensures that the offsets of both the instruction and the fixup fields of each entry are relative to their final location after sorting.
Commit eb608fb366de ("s390/exceptions: switch to relative exception table entries") ported the relative exception table format from x86, but modified the sorting routine to only normalize the instruction offset field and not the fixup offset field. The result is that the fixup offset of each entry will be relative to the original location of the entry before sorting, likely leading to crashes when those entries are dereferenced.
--- arch/s390/mm/extable.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/s390/mm/extable.c +6 -2
@@ -52,12 +52,16 @@ void sort_extable(struct exception_table_entry *start,int i;/* Normalize entries to being relative to the start of the section */ -for (p = start, i =0 ; p < finish; p++, i +=8 ) +for (p = start, i =0 ; p < finish; p++, i +=8 ) { p->insn += i; + p->fixup += i +4 ; + }sort (start, finish - start,sizeof (*start), cmp_ex,NULL );/* Denormalize all entries */ -for (p = start, i =0 ; p < finish; p++, i +=8 ) +for (p = start, i =0 ; p < finish; p++, i +=8 ) { p->insn -= i; + p->fixup -= i +4 ; + } }#ifdef CONFIG_MODULES
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] xfs: handle dquot buffer readahead in log recovery correctly
In reply to Sasha LevinFrom: Dave Chinner <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7d6a13f023567d573ac362502bb702eda716e654 ]
When we do dquot readahead in log recovery, we do not use a verifier as the underlying buffer may not have dquots in it. e.g. the allocation operation hasn't yet been replayed. Hence we do not want to fail recovery because we detect an operation to be replayed has not been run yet. This problem was addressed for inodes in commit d891400 ("xfs: inode buffers may not be valid during recovery readahead") but the problem was not recognised to exist for dquots and their buffers as the dquot readahead did not have a verifier.
The result of not using a verifier is that when the buffer is then next read to replay a dquot modification, the dquot buffer verifier will only be attached to the buffer if *readahead is not complete*. Hence we can read the buffer, replay the dquot changes and then add it to the delwri submission list without it having a verifier attached to it. This then generates warnings in xfs_buf_ioapply(), which catches and warns about this case.
Fix this and make it handle the same readahead verifier error cases as for inode buffers by adding a new readahead verifier that has a write operation as well as a read operation that marks the buffer as not done if any corruption is detected. Also make sure we don't run readahead if the dquot buffer has been marked as cancelled by recovery.
This will result in readahead either succeeding and the buffer having a valid write verifier, or readahead failing and the buffer state requiring the subsequent read to resubmit the IO with the new verifier. In either case, this will result in the buffer always ending up with a valid write verifier on it.
Note: we also need to fix the inode buffer readahead error handling to mark the buffer with EIO. Brian noticed the code I copied from there wrong during review, so fix it at the same time. Add comments linking the two functions that handle readahead verifier errors together so we don't forget this behavioural link in future.
--- fs/xfs/libxfs/xfs_dquot_buf.c | 35 +++++++++++++++++++++++++++++------ fs/xfs/libxfs/xfs_inode_buf.c | 2 ++ fs/xfs/libxfs/xfs_quota_defs.h | 2 +- fs/xfs/libxfs/xfs_shared.h | 1 + fs/xfs/xfs_log_recover.c | 9 +++++++-- 5 files changed, 40 insertions(+), 9 deletions(-)
fs/xfs/libxfs/xfs_dquot_buf.c +29 -6
@@ -54,7 +54,7 @@ xfs_dqcheck(xfs_dqid_t id, uint type, /* used only when IO_dorepair is true */ uint flags, - char *str) + const char *str) { xfs_dqblk_t *d = (xfs_dqblk_t *)ddq;int errs =0 ;
@@ -207,7 +207,8 @@ xfs_dquot_buf_verify_crc( STATIC boolxfs_dquot_buf_verify (struct xfs_mount *mp, -struct xfs_buf *bp) +struct xfs_buf *bp, +int warn) {struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr;xfs_dqid_t id =0 ;
@@ -240,8 +241,7 @@ xfs_dquot_buf_verify(if (i ==0 ) id =be32_to_cpu (ddq->d_id); - error =xfs_dqcheck (mp, ddq, id + i,0 ,XFS_QMOPT_DOWARN , -"xfs_dquot_buf_verify" ); + error =xfs_dqcheck (mp, ddq, id + i,0 , warn, __func__);if (error)return false; }
@@ -256,7 +256,7 @@ xfs_dquot_buf_read_verify(if (!xfs_dquot_buf_verify_crc (mp, bp))xfs_buf_ioerror (bp, -EFSBADCRC ); -else if (!xfs_dquot_buf_verify (mp, bp)) +else if (!xfs_dquot_buf_verify (mp, bp,XFS_QMOPT_DOWARN ))xfs_buf_ioerror (bp, -EFSCORRUPTED );if (bp->b_error)
@@ -264,6 +264,25 @@ xfs_dquot_buf_read_verify( }/* +* readahead errors are silent and simply leave the buffer as !done so a real +* read will then be run with the xfs_dquot_buf_ops verifier. See +* xfs_inode_buf_verify() for why we use EIO and ~XBF_DONE here rather than +* reporting the failure. +*/ +static void +xfs_dquot_buf_readahead_verify ( +struct xfs_buf *bp) +{ +struct xfs_mount *mp = bp->b_target->bt_mount; + +if (!xfs_dquot_buf_verify_crc (mp, bp) || + !xfs_dquot_buf_verify (mp, bp,0 )) { +xfs_buf_ioerror (bp, -EIO ); + bp->b_flags &= ~XBF_DONE ; + } +} + +/* * we don't calculate the CRC here as that is done when the dquot is flushed to * the buffer after the update is done. This ensures that the dquot in the * buffer always has an up-to-date CRC value.
@@ -274,7 +293,7 @@ xfs_dquot_buf_write_verify( {struct xfs_mount *mp = bp->b_target->bt_mount; -if (!xfs_dquot_buf_verify (mp, bp)) { +if (!xfs_dquot_buf_verify (mp, bp,XFS_QMOPT_DOWARN )) {xfs_buf_ioerror (bp, -EFSCORRUPTED );xfs_verifier_error (bp);return ;
@@ -286,3 +305,7 @@ const struct xfs_buf_ops xfs_dquot_buf_ops = { .verify_write = xfs_dquot_buf_write_verify, }; +const struct xfs_buf_ops xfs_dquot_buf_ra_ops = { + .verify_read = xfs_dquot_buf_readahead_verify, + .verify_write = xfs_dquot_buf_write_verify, +};
fs/xfs/libxfs/xfs_inode_buf.c +2 -0
@@ -69,6 +69,8 @@ xfs_inobp_check(* recovery and we don't get unnecssary panics on debug kernels. We use EIO here * because all we want to do is say readahead failed; there is no-one to report * the error to, so this will distinguish it from a non-ra verifier failure. +* Changes to this readahead error behavour also need to be reflected in +* xfs_dquot_buf_readahead_verify(). */ static void xfs_inode_buf_verify(
fs/xfs/libxfs/xfs_quota_defs.h +1 -1
@@ -153,7 +153,7 @@ typedef __uint16_t xfs_qwarncnt_t;#define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)extern int xfs_dqcheck (struct xfs_mount *mp,xfs_disk_dquot_t *ddq, -xfs_dqid_t id,uint type,uint flags,char *str); +xfs_dqid_t id,uint type,uint flags,const char *str);extern int xfs_calc_dquots_per_chunk (unsigned int nbblks);#endif /* __XFS_QUOTA_H__ */
fs/xfs/libxfs/xfs_shared.h +1 -0
@@ -49,6 +49,7 @@ extern const struct xfs_buf_ops xfs_inobt_buf_ops;extern const struct xfs_buf_ops xfs_inode_buf_ops;extern const struct xfs_buf_ops xfs_inode_buf_ra_ops;extern const struct xfs_buf_ops xfs_dquot_buf_ops; +extern const struct xfs_buf_ops xfs_dquot_buf_ra_ops;extern const struct xfs_buf_ops xfs_sb_buf_ops;extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;extern const struct xfs_buf_ops xfs_symlink_buf_ops;
fs/xfs/xfs_log_recover.c +7 -2
@@ -3154,6 +3154,7 @@ xlog_recover_dquot_ra_pass2(struct xfs_disk_dquot *recddq;struct xfs_dq_logformat *dq_f;uint type; +int len;if (mp->m_qflags ==0 )
@@ -3174,8 +3175,12 @@ xlog_recover_dquot_ra_pass2(ASSERT (dq_f);ASSERT (dq_f->qlf_len ==1 ); -xfs_buf_readahead (mp->m_ddev_targp, dq_f->qlf_blkno, -XFS_FSB_TO_BB (mp, dq_f->qlf_len),NULL ); + len =XFS_FSB_TO_BB (mp, dq_f->qlf_len); +if (xlog_peek_buffer_cancelled (log, dq_f->qlf_blkno, len,0 )) +return ; + +xfs_buf_readahead (mp->m_ddev_targp, dq_f->qlf_blkno, len, + &xfs_dquot_buf_ra_ops); }STATIC void
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] parisc: Fix __ARCH_SI_PREAMBLE_SIZE
In reply to Sasha LevinFrom: Helge Deller <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e60fc5aa608eb38b47ba4ee058f306f739eb70a0 ]
On a 64bit kernel build the compiler aligns the _sifields union in the struct siginfo_t on a 64bit address. The __ARCH_SI_PREAMBLE_SIZE define compensates for this alignment and thus fixes the wait testcase of the strace package.
The symptoms of a wrong __ARCH_SI_PREAMBLE_SIZE value is that _sigchld.si_stime variable is missed to be copied and thus after a copy_siginfo() will have uninitialized values.
--- arch/parisc/include/uapi/asm/siginfo.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/parisc/include/uapi/asm/siginfo.h +4 -0
@@ -1,6 +1,10 @@#ifndef _PARISC_SIGINFO_H#define _PARISC_SIGINFO_H +#if defined(__LP64__) +#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) +#endif +#include <asm-generic/siginfo.h> #undef NSIGTRAP
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] virtio_balloon: fix race by fill and leak
In reply to Sasha LevinFrom: Minchan Kim <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f68b992bbb474641881932c61c92dcfa6f5b3689 ]
During my compaction-related stuff, I encountered a bug with ballooning.
With repeated inflating and deflating cycle, guest memory( ie, cat /proc/meminfo | grep MemTotal) is decreased and couldn't be recovered.
The reason is balloon_lock doesn't cover release_pages_balloon so struct virtio_balloon fields could be overwritten by race of fill_balloon(e,g, vb->*pfns could be critical).
This patch fixes it in my test.
--- drivers/virtio/virtio_balloon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +1 -1
@@ -205,8 +205,8 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num)*/ if (vb->num_pfns !=0 )tell_host (vb, vb->deflate_vq); -mutex_unlock (&vb->balloon_lock);release_pages_balloon (vb); +mutex_unlock (&vb->balloon_lock);return num_freed_pages; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] virtio_balloon: fix race between migration and ballooning
In reply to Sasha LevinFrom: Minchan Kim <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 21ea9fb69e7c4b1b1559c3e410943d3ff248ffcb ]
In balloon_page_dequeue, pages_lock should cover the loop (ie, list_for_each_entry_safe). Otherwise, the cursor page could be isolated by compaction and then list_del by isolation could poison the page->lru.{prev,next} so the loop finally could access wrong address like this. This patch fixes the bug.
general protection fault: 0000 [#1] SMP Dumping ftrace buffer: (ftrace buffer empty) Modules linked in: CPU: 2 PID: 82 Comm: vballoon Not tainted 4.4.0-rc5-mm1-access_bit+ #1906 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 task: ffff8800a7ff0000 ti: ffff8800a7fec000 task.ti: ffff8800a7fec000 RIP: 0010:[<ffffffff8115e754>] [<ffffffff8115e754>] balloon_page_dequeue+0x54/0x130 RSP: 0018:ffff8800a7fefdc0 EFLAGS: 00010246 RAX: ffff88013fff9a70 RBX: ffffea000056fe00 RCX: 0000000000002b7d RDX: ffff88013fff9a70 RSI: ffffea000056fe00 RDI: ffff88013fff9a68 RBP: ffff8800a7fefde8 R08: ffffea000056fda0 R09: 0000000000000000 R10: ffff8800a7fefd90 R11: 0000000000000001 R12: dead0000000000e0 R13: ffffea000056fe20 R14: ffff880138809070 R15: ffff880138809060 FS: 0000000000000000(0000) GS:ffff88013fc40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: 00007f229c10e000 CR3: 00000000b8b53000 CR4: 00000000000006a0 Stack: 0000000000000100 ffff880138809088 ffff880138809000 ffff880138809060 0000000000000046 ffff8800a7fefe28 ffffffff812c86d3 ffff880138809020 ffff880138809000 fffffffffff91900 0000000000000100 ffff880138809060 Call Trace: [<ffffffff812c86d3>] leak_balloon+0x93/0x1a0 [<ffffffff812c8bc7>] balloon+0x217/0x2a0 [<ffffffff8143739e>] ? __schedule+0x31e/0x8b0 [<ffffffff81078160>] ? abort_exclusive_wait+0xb0/0xb0 [<ffffffff812c89b0>] ? update_balloon_stats+0xf0/0xf0 [<ffffffff8105b6e9>] kthread+0xc9/0xe0 [<ffffffff8105b620>] ? kthread_park+0x60/0x60 [<ffffffff8143b4af>] ret_from_fork+0x3f/0x70 [<ffffffff8105b620>] ? kthread_park+0x60/0x60 Code: 8d 60 e0 0f 84 af 00 00 00 48 8b 43 20 a8 01 75 3b 48 89 d8 f0 0f ba 28 00 72 10 48 8b 03 f6 c4 08 75 2f 48 89 df e8 8c 83 f9 ff <49> 8b 44 24 20 4d 8d 6c 24 20 48 83 e8 20 4d 39 f5 74 7a 4c 89 RIP [<ffffffff8115e754>] balloon_page_dequeue+0x54/0x130 RSP <ffff8800a7fefdc0> ---[ end trace 43cf28060d708d5f ]--- Kernel panic - not syncing: Fatal exception
Dumping ftrace buffer:
(ftrace buffer empty)
Kernel Offset: disabled
--- mm/balloon_compaction.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/balloon_compaction.c +2 -2
@@ -61,6 +61,7 @@ struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info)bool dequeued_page; dequeued_page = false; +spin_lock_irqsave (&b_dev_info->pages_lock, flags);list_for_each_entry_safe (page, tmp, &b_dev_info->pages, lru) {/* * Block others from accessing the 'page' while we get around
@@ -75,15 +76,14 @@ struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info) continue; }#endif -spin_lock_irqsave (&b_dev_info->pages_lock, flags);balloon_page_delete (page);__count_vm_event (BALLOON_DEFLATE ); -spin_unlock_irqrestore (&b_dev_info->pages_lock, flags);unlock_page (page); dequeued_page = true;break ; } } +spin_unlock_irqrestore (&b_dev_info->pages_lock, flags);if (!dequeued_page) {/*
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] mmc: mmci: fix an ages old detection error
In reply to Sasha LevinFrom: Linus Walleij <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0bcb7efdff63564e80fe84dd36a9fbdfbf6697a4 ]
commit 4956e10903fd ("ARM: 6244/1: mmci: add variant data and default MCICLOCK support") added variant data for ARM, U300 and Ux500 variants. The Nomadik NHK8815/8820 variant was erroneously labeled as a U300 variant, and when the proper Nomadik variant was later introduced in commit 34fd421349ff ("ARM: 7378/1: mmci: add support for the Nomadik MMCI variant") this was not fixes. Let's say this fixes the latter commit as there was no proper Nomadik support until then.
--- drivers/mmc/host/mmci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/mmci.c +1 -1
@@ -1886,7 +1886,7 @@ static struct amba_id mmci_ids[] = { { .id = 0x00280180, .mask = 0x00ffffff, - .data = &variant_u300, + .data = &variant_nomadik, }, { .id = 0x00480180,
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] virtio_ballon: change stub of release_pages_by_pfn
In reply to Sasha LevinFrom: "Denis V. Lunev" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b4d34037329f46ed818d3b0a6e1e23b9c8721f79 ]
and rename it to release_pages_balloon. The function originally takes arrays of pfns and now it takes pointer to struct virtio_ballon. This change is necessary to conditionally call adjust_managed_page_count in the next patch.
--- drivers/virtio/virtio_balloon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/virtio/virtio_balloon.c +4 -4
@@ -166,13 +166,13 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num)mutex_unlock (&vb->balloon_lock); } -static void release_pages_by_pfn (const u32 pfns[],unsigned int num) +static void release_pages_balloon (struct virtio_balloon *vb) {unsigned int i;/* Find pfns pointing at start of each page, get pages and free them. */ -for (i =0 ; i < num; i +=VIRTIO_BALLOON_PAGES_PER_PAGE ) { -struct page *page =balloon_pfn_to_page (pfns[i]); +for (i =0 ; i < vb->num_pfns; i +=VIRTIO_BALLOON_PAGES_PER_PAGE ) { +struct page *page =balloon_pfn_to_page (vb->pfns[i]);adjust_managed_page_count (page,1 );put_page (page);/* balloon reference */ }
@@ -206,7 +206,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num)if (vb->num_pfns !=0 )tell_host (vb, vb->deflate_vq);mutex_unlock (&vb->balloon_lock); -release_pages_by_pfn (vb->pfns, vb->num_pfns); +release_pages_balloon (vb);return num_freed_pages; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] mmc: core: Enable tuning according to the actual timing
In reply to Sasha LevinFrom: Carlo Caione <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e10c321977091f163eceedec0650e0ef4b3cf4bb ]
While in sdhci_execute_tuning() the choice whether or not to enable the tuning is done on the actual timing, in the mmc_sdio_init_uhs_card() the check is done on the capability of the card.
This difference is causing some issues with some SDIO cards in DDR50 mode where the CDM19 is wrongly issued.
With this patch we modify the check in both mmc_(sd|sdio)_init_uhs_card() functions to take the proper decision only according to the actual timing specification.
--- drivers/mmc/core/sd.c | 8 ++++---- drivers/mmc/core/sdio.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/mmc/core/sd.c +4 -4
@@ -661,9 +661,9 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104. */ if (!mmc_host_is_spi (card->host) && - (card->sd_bus_speed ==UHS_SDR50_BUS_SPEED || - card->sd_bus_speed ==UHS_DDR50_BUS_SPEED || - card->sd_bus_speed ==UHS_SDR104_BUS_SPEED )) { + (card->host->ios.timing ==MMC_TIMING_UHS_SDR50 || + card->host->ios.timing ==MMC_TIMING_UHS_DDR50 || + card->host->ios.timing ==MMC_TIMING_UHS_SDR104 )) { err =mmc_execute_tuning (card);/*
@@ -673,7 +673,7 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)* difference between v3.00 and 3.01 spec means that CMD19 * tuning is also available for DDR50 mode. */ -if (err && card->sd_bus_speed ==UHS_DDR50_BUS_SPEED ) { +if (err && card->host->ios.timing ==MMC_TIMING_UHS_DDR50 ) {pr_warn ("%s: ddr50 tuning failed\n" ,mmc_hostname (card->host)); err =0 ;
drivers/mmc/core/sdio.c +2 -2
@@ -566,8 +566,8 @@ static int mmc_sdio_init_uhs_card(struct mmc_card *card)* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104. */ if (!mmc_host_is_spi (card->host) && - ((card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR50 ) || - (card->sw_caps.sd3_bus_mode &SD_MODE_UHS_SDR104 ))) + ((card->host->ios.timing ==MMC_TIMING_UHS_SDR50 ) || + (card->host->ios.timing ==MMC_TIMING_UHS_SDR104 ))) err =mmc_execute_tuning (card); out:return err;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] cifs: Ratelimit kernel log messages
In reply to Sasha LevinFrom: Jamie Bainbridge <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ec7147a99e33a9e4abad6fc6e1b40d15df045d53 ]
Under some conditions, CIFS can repeatedly call the cifs_dbg() logging wrapper. If done rapidly enough, the console framebuffer can softlockup or "rcu_sched self-detected stall". Apply the built-in log ratelimiters to prevent such hangs.
--- fs/cifs/cifs_debug.c | 2 +- fs/cifs/cifs_debug.h | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-)
fs/cifs/cifs_debug.c +1 -1
@@ -50,7 +50,7 @@ void cifs_vfs_err(const char *fmt, ...) vaf.fmt = fmt; vaf.va = &args; -pr_err ("CIFS VFS: %pV" , &vaf); +pr_err_ratelimited ("CIFS VFS: %pV" , &vaf);va_end (args); }
fs/cifs/cifs_debug.h +4 -5
@@ -51,14 +51,13 @@ __printf(1, 2) void cifs_vfs_err(const char *fmt, ...);/* information message: e.g., configuration, major event */ #define cifs_dbg (type, fmt, ...) \ do { \ - if (type == FYI) { \ - if (cifsFYI & CIFS_INFO) { \ - pr_debug("%s: " fmt, __FILE__, ##__VA_ARGS__); \ - } \ + if (type == FYI && cifsFYI & CIFS_INFO) { \ + pr_debug_ratelimited("%s: " \ + fmt, __FILE__, ##__VA_ARGS__); \ } else if (type == VFS) { \ cifs_vfs_err(fmt, ##__VA_ARGS__); \ } else if (type == NOISY && type != 0) { \ - pr_debug(fmt, ##__VA_ARGS__); \ + pr_debug_ratelimited(fmt, ##__VA_ARGS__); \ } \ } while (0)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] clocksource/drivers/vt8500: Increase the minimum delta
In reply to Sasha LevinFrom: Roman Volkov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f9eccf24615672896dc13251410c3f2f33a14f95 ]
The vt8500 clocksource driver declares itself as capable to handle the minimum delay of 4 cycles by passing the value into clockevents_config_and_register(). The vt8500_timer_set_next_event() requires the passed cycles value to be at least 16. The impact is that userspace hangs in nanosleep() calls with small delay intervals.
This problem is reproducible in Linux 4.2 starting from:c6eb3f70d448 ('hrtimer: Get rid of hrtimer softirq')
Quoted 1 line
From Russell King, more detailed explanation:
"It's a speciality of the StrongARM/PXA hardware. It takes a certain number of OSCR cycles for the value written to hit the compare registers. So, if a very small delta is written (eg, the compare register is written with a value of OSCR + 1), the OSCR will have incremented past this value before it hits the underlying hardware. The result is, that you end up waiting a very long time for the OSCR to wrap before the event fires.
So, we introduce a check in set_next_event() to detect this and return -ETIME if the calculated delta is too small, which causes the generic clockevents code to retry after adding the min_delta specified in clockevents_config_and_register() to the current time value.
min_delta must be sufficient that we don't re-trip the -ETIME check - if we do, we will return -ETIME, forward the next event time, try to set it, return -ETIME again, and basically lock the system up. So, min_delta must be larger than the check inside set_next_event(). A factor of two was chosen to ensure that this situation would never occur.
The PXA code worked on PXA systems for years, and I'd suggest no one changes this mechanism without access to a wide range of PXA systems, otherwise they're risking breakage."
--- drivers/clocksource/vt8500_timer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clocksource/vt8500_timer.c +4 -2
@@ -50,6 +50,8 @@#define msecs_to_loops (t) (loops_per_jiffy / 1000 * HZ * t) +#define MIN_OSCR_DELTA 16 +static void __iomem *regbase;static cycle_t vt8500_timer_read (struct clocksource *cs)
@@ -80,7 +82,7 @@ static int vt8500_timer_set_next_event(unsigned long cycles,cpu_relax ();writel ((unsigned long )alarm, regbase +TIMER_MATCH_VAL ); -if ((signed )(alarm - clocksource.read (&clocksource)) <=16 ) +if ((signed )(alarm - clocksource.read (&clocksource)) <=MIN_OSCR_DELTA )return -ETIME ;writel (1 , regbase +TIMER_IER_VAL );
@@ -160,7 +162,7 @@ static void __init vt8500_timer_init(struct device_node *np)pr_err ("%s: setup_irq failed for %s\n" , __func__, clockevent.name);clockevents_config_and_register (&clockevent,VT8500_TIMER_HZ , -4 ,0xf0000000 ); +MIN_OSCR_DELTA *2 ,0xf0000000 ); }CLOCKSOURCE_OF_DECLARE (vt8500,"via,vt8500-timer" , vt8500_timer_init);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] dmaengine: dw: fix cyclic transfer setup
In reply to Sasha LevinFrom: Mans Rullgard <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit df3bb8a0e619d501cd13334c3e0586edcdcbc716 ]
Commit 61e183f83069 ("dmaengine/dw_dmac: Reconfigure interrupt and chan_cfg register on resume") moved some channel initialisation to a new function which must be called before starting a transfer.
This updates dw_dma_cyclic_start() to use dwc_dostart() like the other modes, thus ensuring dwc_initialize() gets called and removing some code duplication.
--- drivers/dma/dw/core.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/dma/dw/core.c +1 -22
@@ -1245,7 +1245,6 @@ static void dwc_free_chan_resources(struct dma_chan *chan)int dw_dma_cyclic_start (struct dma_chan *chan) {struct dw_dma_chan *dwc =to_dw_dma_chan (chan); -struct dw_dma *dw =to_dw_dma (dwc->chan.device);unsigned long flags;if (!test_bit (DW_DMA_IS_CYCLIC , &dwc->flags)) {
@@ -1254,27 +1253,7 @@ int dw_dma_cyclic_start(struct dma_chan *chan) }spin_lock_irqsave (&dwc->lock, flags); - -/* Assert channel is idle */ -if (dma_readl (dw,CH_EN ) & dwc->mask) { -dev_err (chan2dev (&dwc->chan), -"%s: BUG: Attempted to start non-idle channel\n" , - __func__); -dwc_dump_chan_regs (dwc); -spin_unlock_irqrestore (&dwc->lock, flags); -return -EBUSY ; - } - -dma_writel (dw,CLEAR .ERROR, dwc->mask); -dma_writel (dw,CLEAR .XFER, dwc->mask); - -/* Setup DMAC channel registers */ -channel_writel (dwc,LLP , dwc->cdesc->desc[0 ]->txd.phys); -channel_writel (dwc,CTL_LO ,DWC_CTLL_LLP_D_EN |DWC_CTLL_LLP_S_EN ); -channel_writel (dwc,CTL_HI ,0 ); - -channel_set_bit (dw,CH_EN , dwc->mask); - +dwc_dostart (dwc, dwc->cdesc->desc[0 ]);spin_unlock_irqrestore (&dwc->lock, flags);return 0 ;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] dmaengine: dw: fix cyclic transfer callbacks
In reply to Sasha LevinFrom: Mans Rullgard <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 2895b2cad6e7a95104cf396e5330054453382ae1 ]
Cyclic transfer callbacks rely on block completion interrupts which were disabled in commit ff7b05f29fd4 ("dmaengine/dw_dmac: Don't handle block interrupts"). This re-enables block interrupts so the cyclic callbacks can work. Other transfer types are not affected as they set the INT_EN bit only on the last block.
--- drivers/dma/dw/core.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/dma/dw/core.c +15 -6
@@ -156,6 +156,7 @@ static void dwc_initialize(struct dw_dma_chan *dwc)/* Enable interrupts */ channel_set_bit (dw,MASK .XFER, dwc->mask); +channel_set_bit (dw,MASK .BLOCK, dwc->mask);channel_set_bit (dw,MASK .ERROR, dwc->mask); dwc->initialized = true;
@@ -536,16 +537,17 @@ EXPORT_SYMBOL(dw_dma_get_dst_addr);/* Called with dwc->lock held and all DMAC interrupts disabled */ static void dwc_handle_cyclic (struct dw_dma *dw,struct dw_dma_chan *dwc, -u32 status_err,u32 status_xfer) +u32 status_block,u32 status_err,u32 status_xfer) {unsigned long flags; -if (dwc->mask) { +if (status_block & dwc->mask) {void (*callback)(void *param);void *callback_param;dev_vdbg (chan2dev (&dwc->chan),"new cyclic period llp 0x%08x\n" ,channel_readl (dwc,LLP )); +dma_writel (dw,CLEAR .BLOCK, dwc->mask); callback = dwc->cdesc->period_callback; callback_param = dwc->cdesc->period_callback_param;
@@ -577,6 +579,7 @@ static void dwc_handle_cyclic(struct dw_dma *dw, struct dw_dma_chan *dwc,channel_writel (dwc,CTL_LO ,0 );channel_writel (dwc,CTL_HI ,0 ); +dma_writel (dw,CLEAR .BLOCK, dwc->mask);dma_writel (dw,CLEAR .ERROR, dwc->mask);dma_writel (dw,CLEAR .XFER, dwc->mask);
@@ -593,10 +596,12 @@ static void dw_dma_tasklet(unsigned long data) {struct dw_dma *dw = (struct dw_dma *)data;struct dw_dma_chan *dwc; +u32 status_block;u32 status_xfer;u32 status_err;int i; + status_block =dma_readl (dw,RAW .BLOCK); status_xfer =dma_readl (dw,RAW .XFER); status_err =dma_readl (dw,RAW .ERROR);
@@ -605,7 +610,8 @@ static void dw_dma_tasklet(unsigned long data)for (i =0 ; i < dw->dma.chancnt; i++) { dwc = &dw->chan[i];if (test_bit (DW_DMA_IS_CYCLIC , &dwc->flags)) -dwc_handle_cyclic (dw, dwc, status_err, status_xfer); +dwc_handle_cyclic (dw, dwc, status_block, status_err, + status_xfer);else if (status_err & (1 << i))dwc_handle_error (dw, dwc);else if (status_xfer & (1 << i))
@@ -616,6 +622,7 @@ static void dw_dma_tasklet(unsigned long data)* Re-enable interrupts. */ channel_set_bit (dw,MASK .XFER, dw->all_chan_mask); +channel_set_bit (dw,MASK .BLOCK, dw->all_chan_mask);channel_set_bit (dw,MASK .ERROR, dw->all_chan_mask); }
@@ -635,6 +642,7 @@ static irqreturn_t dw_dma_interrupt(int irq, void *dev_id)* softirq handler. */ channel_clear_bit (dw,MASK .XFER, dw->all_chan_mask); +channel_clear_bit (dw,MASK .BLOCK, dw->all_chan_mask);channel_clear_bit (dw,MASK .ERROR, dw->all_chan_mask); status =dma_readl (dw,STATUS_INT );
@@ -645,6 +653,7 @@ static irqreturn_t dw_dma_interrupt(int irq, void *dev_id)/* Try to recover */ channel_clear_bit (dw,MASK .XFER, (1 <<8 ) -1 ); +channel_clear_bit (dw,MASK .BLOCK, (1 <<8 ) -1 );channel_clear_bit (dw,MASK .SRC_TRAN, (1 <<8 ) -1 );channel_clear_bit (dw,MASK .DST_TRAN, (1 <<8 ) -1 );channel_clear_bit (dw,MASK .ERROR, (1 <<8 ) -1 );
@@ -1111,6 +1120,7 @@ static void dw_dma_off(struct dw_dma *dw)dma_writel (dw,CFG ,0 );channel_clear_bit (dw,MASK .XFER, dw->all_chan_mask); +channel_clear_bit (dw,MASK .BLOCK, dw->all_chan_mask);channel_clear_bit (dw,MASK .SRC_TRAN, dw->all_chan_mask);channel_clear_bit (dw,MASK .DST_TRAN, dw->all_chan_mask);channel_clear_bit (dw,MASK .ERROR, dw->all_chan_mask);
@@ -1216,6 +1226,7 @@ static void dwc_free_chan_resources(struct dma_chan *chan)/* Disable interrupts */ channel_clear_bit (dw,MASK .XFER, dwc->mask); +channel_clear_bit (dw,MASK .BLOCK, dwc->mask);channel_clear_bit (dw,MASK .ERROR, dwc->mask);spin_unlock_irqrestore (&dwc->lock, flags);
@@ -1458,6 +1469,7 @@ void dw_dma_cyclic_free(struct dma_chan *chan)dwc_chan_disable (dw, dwc); +dma_writel (dw,CLEAR .BLOCK, dwc->mask);dma_writel (dw,CLEAR .ERROR, dwc->mask);dma_writel (dw,CLEAR .XFER, dwc->mask);
@@ -1548,9 +1560,6 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)/* Force dma off, just in case */ dw_dma_off (dw); -/* Disable BLOCK interrupts as well */ -channel_clear_bit (dw,MASK .BLOCK, dw->all_chan_mask); -/* Create a pool of consistent memory blocks for hardware descriptors */ dw->desc_pool =dmam_pool_create ("dw_dmac_desc_pool" , chip->dev,sizeof (struct dw_desc ),4 ,0 );
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] cifs_dbg() outputs an uninitialized buffer in cifs_readdir()
In reply to Sasha LevinFrom: Vasily Averin <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 01b9b0b28626db4a47d7f48744d70abca9914ef1 ]
In some cases tmp_bug can be not filled in cifs_filldir and stay uninitialized, therefore its printk with "%s" modifier can leak content of kernelspace memory. If old content of this buffer does not contain '\0' access bejond end of allocated object can crash the host.
--- fs/cifs/readdir.c | 1 + 1 file changed, 1 insertion(+)
fs/cifs/readdir.c +1 -0
@@ -847,6 +847,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)* if buggy server returns . and .. late do we want to * check for that here? */ + *tmp_buf =0 ; rc =cifs_filldir (current_entry, file, ctx, tmp_buf, max_len);if (rc) {
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] sparc64: fix incorrect sign extension in sys_sparc64_personality
In reply to Sasha LevinFrom: "Dmitry V. Levin" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 525fd5a94e1be0776fa652df5c687697db508c91 ]
The value returned by sys_personality has type "long int". It is saved to a variable of type "int", which is not a problem yet because the type of task_struct->pesonality is "unsigned int". The problem is the sign extension from "int" to "long int" that happens on return from sys_sparc64_personality.
For example, a userspace call personality((unsigned) -EINVAL) will result to any subsequent personality call, including absolutely harmless read-only personality(0xffffffff) call, failing with errno set to EINVAL.
--- arch/sparc/kernel/sys_sparc_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/sys_sparc_64.c +1 -1
@@ -413,7 +413,7 @@ out: SYSCALL_DEFINE1(sparc64_personality, unsigned long, personality) { -int ret; +long ret;if (personality (current->personality) ==PER_LINUX32 &&personality (personality) ==PER_LINUX )
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] mmc: core: enable CMD19 tuning for DDR50 mode
In reply to Sasha LevinFrom: Weijun Yang <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4324f6de6d2eb9b232410eb0d67bfafdde8ba711 ]
As SD Specifications Part1 Physical Layer Specification Version 3.01 says, CMD19 tuning is available for unlocked cards in transfer state of 1.8V signaling mode. The small difference between v3.00 and 3.01 spec means that CMD19 tuning is also available for DDR50 mode.
--- drivers/mmc/core/sd.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/mmc/core/sd.c +18 -2
@@ -661,9 +661,25 @@ static int mmc_sd_init_uhs_card(struct mmc_card *card)* SDR104 mode SD-cards. Note that tuning is mandatory for SDR104. */ if (!mmc_host_is_spi (card->host) && - (card->sd_bus_speed ==UHS_SDR50_BUS_SPEED || - card->sd_bus_speed ==UHS_SDR104_BUS_SPEED )) + (card->sd_bus_speed ==UHS_SDR50_BUS_SPEED || + card->sd_bus_speed ==UHS_DDR50_BUS_SPEED || + card->sd_bus_speed ==UHS_SDR104_BUS_SPEED )) { err =mmc_execute_tuning (card); + +/* +* As SD Specifications Part1 Physical Layer Specification +* Version 3.01 says, CMD19 tuning is available for unlocked +* cards in transfer state of 1.8V signaling mode. The small +* difference between v3.00 and 3.01 spec means that CMD19 +* tuning is also available for DDR50 mode. +*/ +if (err && card->sd_bus_speed ==UHS_DDR50_BUS_SPEED ) { +pr_warn ("%s: ddr50 tuning failed\n" , +mmc_hostname (card->host)); + err =0 ; + } + } + out:kfree (status);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] cifs: fix race between call_async() and reconnect()
In reply to Sasha LevinFrom: Rabin Vincent <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 820962dc700598ffe8cd21b967e30e7520c34748 ]
cifs_call_async() queues the MID to the pending list and calls smb_send_rqst(). If smb_send_rqst() performs a partial send, it sets the tcpStatus to CifsNeedReconnect and returns an error code to cifs_call_async(). In this case, cifs_call_async() removes the MID from the list and returns to the caller.
However, cifs_call_async() releases the server mutex _before_ removing the MID. This means that a cifs_reconnect() can race with this function and manage to remove the MID from the list and delete the entry before cifs_call_async() calls cifs_delete_mid(). This leads to various crashes due to the use after free in cifs_delete_mid().
Task1 Task2
cifs_call_async():
- rc = -EAGAIN
- mutex_unlock(srv_mutex)
cifs_reconnect():
- mutex_lock(srv_mutex)
- mutex_unlock(srv_mutex)
- list_delete(mid)
- mid->callback() cifs_writev_callback():
- mutex_lock(srv_mutex)
- delete(mid)
- mutex_unlock(srv_mutex)
- cifs_delete_mid(mid) <---- use after free
Fix this by removing the MID in cifs_call_async() before releasing the srv_mutex. Also hold the srv_mutex in cifs_reconnect() until the MIDs are moved out of the pending list.
--- fs/cifs/connect.c | 2 +- fs/cifs/transport.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)
fs/cifs/connect.c +1 -1
@@ -357,7 +357,6 @@ cifs_reconnect(struct TCP_Server_Info *server) server->session_key.response =NULL ; server->session_key.len =0 ; server->lstrp = jiffies; -mutex_unlock (&server->srv_mutex);/* mark submitted MIDs for retry and issue callback */ INIT_LIST_HEAD (&retry_list);
@@ -370,6 +369,7 @@ cifs_reconnect(struct TCP_Server_Info *server)list_move (&mid_entry->qhead, &retry_list); }spin_unlock (&GlobalMid_Lock); +mutex_unlock (&server->srv_mutex);cifs_dbg (FYI ,"%s: issuing mid callbacks\n" , __func__);list_for_each_safe (tmp, tmp2, &retry_list) {
fs/cifs/transport.c +4 -2
@@ -576,14 +576,16 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,cifs_in_send_dec (server);cifs_save_when_sent (mid); -if (rc <0 ) +if (rc <0 ) { server->sequence_number -=2 ; +cifs_delete_mid (mid); + } +mutex_unlock (&server->srv_mutex);if (rc ==0 )return 0 ; -cifs_delete_mid (mid);add_credits_and_wake_if (server, credits, optype);return rc; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] scripts/bloat-o-meter: fix python3 syntax error
In reply to Sasha LevinFrom: Sergey Senozhatsky <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 72214a24a7677d4c7501eecc9517ed681b5f2db2 ]
In Python3+ print is a function so the old syntax is not correct anymore:
$ ./scripts/bloat-o-meter vmlinux.o vmlinux.o.old
File "./scripts/bloat-o-meter", line 61
print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \
^
SyntaxError: invalid syntaxFix by calling print as a function.
Tested on python 2.7.11, 3.5.1
--- scripts/bloat-o-meter | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
scripts/bloat-o-meter +4 -4
@@ -58,8 +58,8 @@ for name in common: delta.sort() delta.reverse() -print "add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \ - (add, remove, grow, shrink, up, -down, up-down) -print "%-40s %7s %7s %+7s" % ("function", "old", "new", "delta") +print("add/remove: %s/%s grow/shrink: %s/%s up/down: %s/%s (%s)" % \ + (add, remove, grow, shrink, up, -down, up-down)) +print("%-40s %7s %7s %+7s" % ("function", "old", "new", "delta")) for d, n in delta: - if d: print "%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d) + if d: print("%-40s %7s %7s %+7d" % (n, old.get(n,"-"), new.get(n,"-"), d))
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] KVM: PPC: Fix ONE_REG AltiVec support
In reply to Sasha LevinFrom: Greg Kurz <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b4d7f161feb3015d6306e1d35b565c888ff70c9d ]
The get and set operations got exchanged by mistake when moving the code from book3s.c to powerpc.c.
--- arch/powerpc/kvm/powerpc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
arch/powerpc/kvm/powerpc.c +10 -10
@@ -915,21 +915,17 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) r = -ENXIO ; break; } - vcpu->arch.vr.vr[reg->id -KVM_REG_PPC_VR0 ] = val.vval; + val.vval = vcpu->arch.vr.vr[reg->id -KVM_REG_PPC_VR0 ];break ;case KVM_REG_PPC_VSCR :if (!cpu_has_feature (CPU_FTR_ALTIVEC )) { r = -ENXIO ;break ; } - vcpu->arch.vr.vscr.u[3 ] =set_reg_val (reg->id, val); + val =get_reg_val (reg->id, vcpu->arch.vr.vscr.u[3 ]);break ;case KVM_REG_PPC_VRSAVE : -if (!cpu_has_feature (CPU_FTR_ALTIVEC )) { - r = -ENXIO ; -break ; - } - vcpu->arch.vrsave =set_reg_val (reg->id, val); + val =get_reg_val (reg->id, vcpu->arch.vrsave);break ;#endif /* CONFIG_ALTIVEC */ default :
@@ -970,17 +966,21 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) r = -ENXIO ; break; } - val.vval = vcpu->arch.vr.vr[reg->id -KVM_REG_PPC_VR0 ]; + vcpu->arch.vr.vr[reg->id -KVM_REG_PPC_VR0 ] = val.vval;break ;case KVM_REG_PPC_VSCR :if (!cpu_has_feature (CPU_FTR_ALTIVEC )) { r = -ENXIO ;break ; } - val =get_reg_val (reg->id, vcpu->arch.vr.vscr.u[3 ]); + vcpu->arch.vr.vscr.u[3 ] =set_reg_val (reg->id, val);break ;case KVM_REG_PPC_VRSAVE : - val =get_reg_val (reg->id, vcpu->arch.vrsave); +if (!cpu_has_feature (CPU_FTR_ALTIVEC )) { + r = -ENXIO ; +break ; + } + vcpu->arch.vrsave =set_reg_val (reg->id, val);break ;#endif /* CONFIG_ALTIVEC */ default :
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] m32r: fix m32104ut_defconfig build fail
In reply to Sasha LevinFrom: Sudip Mukherjee <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 601f1db653217f205ffa5fb33514b4e1711e56d1 ]
The build of m32104ut_defconfig for m32r arch was failing for long long time with the error:
ERROR: "memory_start" [fs/udf/udf.ko] undefined!
ERROR: "memory_end" [fs/udf/udf.ko] undefined!
ERROR: "memory_end" [drivers/scsi/sg.ko] undefined!
ERROR: "memory_start" [drivers/scsi/sg.ko] undefined!
ERROR: "memory_end" [drivers/i2c/i2c-dev.ko] undefined!
ERROR: "memory_start" [drivers/i2c/i2c-dev.ko] undefined!
As done in other architectures export the symbols to fix the error.
--- arch/m32r/kernel/setup.c | 3 +++ 1 file changed, 3 insertions(+)
arch/m32r/kernel/setup.c +3 -0
@@ -81,7 +81,10 @@ static struct resource code_resource = { };unsigned long memory_start; +EXPORT_SYMBOL (memory_start); +unsigned long memory_end; +EXPORT_SYMBOL (memory_end);void __init setup_arch (char **);int get_cpuinfo (char *);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] futex: Drop refcount if requeue_pi() acquired the rtmutex
In reply to Sasha LevinFrom: Thomas Gleixner <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fb75a4282d0d9a3c7c44d940582c2d226cf3acfb ]
If the proxy lock in the requeue loop acquires the rtmutex for a waiter then it acquired also refcount on the pi_state related to the futex, but the waiter side does not drop the reference count.
Add the missing free_pi_state() call.
--- kernel/futex.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/futex.c +5 -0
@@ -2632,6 +2632,11 @@ static int futex_wait_requeue_pi(u32 __user *uaddr, unsigned int flags,if (q.pi_state && (q.pi_state->owner != current)) {spin_lock (q.lock_ptr); ret =fixup_pi_state_owner (uaddr2, &q, current); +/* +* Drop the reference to the pi state which +* the requeue_pi() code acquired for us. +*/ +free_pi_state (q.pi_state);spin_unlock (q.lock_ptr); } }else {
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] zram/zcomp: use GFP_NOIO to allocate streams
In reply to Sasha LevinFrom: Sergey Senozhatsky <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 3d5fe03a3ea013060ebba2a811aeb0f23f56aefa ]
We can end up allocating a new compression stream with GFP_KERNEL from within the IO path, which may result is nested (recursive) IO operations. That can introduce problems if the IO path in question is a reclaimer, holding some locks that will deadlock nested IOs.
Allocate streams and working memory using GFP_NOIO flag, forbidding recursive IO and FS operations.
An example:
inconsistent {IN-RECLAIM_FS-W} -> {RECLAIM_FS-ON-W} usage. git/20158 [HC0[0]:SC0[0]:HE1:SE1] takes:
(jbd2_handle){+.+.?.}, at: start_this_handle+0x4ca/0x555
{IN-RECLAIM_FS-W} state was registered at:
__lock_acquire+0x8da/0x117b
lock_acquire+0x10c/0x1a7
start_this_handle+0x52d/0x555
jbd2__journal_start+0xb4/0x237
__ext4_journal_start_sb+0x108/0x17e
ext4_dirty_inode+0x32/0x61
__mark_inode_dirty+0x16b/0x60c
iput+0x11e/0x274
__dentry_kill+0x148/0x1b8
shrink_dentry_list+0x274/0x44a
prune_dcache_sb+0x4a/0x55
super_cache_scan+0xfc/0x176
shrink_slab.part.14.constprop.25+0x2a2/0x4d3
shrink_zone+0x74/0x140
kswapd+0x6b7/0x930
kthread+0x107/0x10f
ret_from_fork+0x3f/0x70
irq event stamp: 138297
hardirqs last enabled at (138297): debug_check_no_locks_freed+0x113/0x12f
hardirqs last disabled at (138296): debug_check_no_locks_freed+0x33/0x12f
softirqs last enabled at (137818): __do_softirq+0x2d3/0x3e9
softirqs last disabled at (137813): irq_exit+0x41/0x95other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(jbd2_handle);
<Interrupt>
lock(jbd2_handle); *** DEADLOCK ***
5 locks held by git/20158:
#0: (sb_writers#7){.+.+.+}, at: [<ffffffff81155411>] mnt_want_write+0x24/0x4b
#1: (&type->i_mutex_dir_key#2/1){+.+.+.}, at: [<ffffffff81145087>] lock_rename+0xd9/0xe3
#2: (&sb->s_type->i_mutex_key#11){+.+.+.}, at: [<ffffffff8114f8e2>] lock_two_nondirectories+0x3f/0x6b
#3: (&sb->s_type->i_mutex_key#11/4){+.+.+.}, at: [<ffffffff8114f909>] lock_two_nondirectories+0x66/0x6b
#4: (jbd2_handle){+.+.?.}, at: [<ffffffff811e31db>] start_this_handle+0x4ca/0x555 stack backtrace:
CPU: 2 PID: 20158 Comm: git Not tainted 4.1.0-rc7-next-20150615-dbg-00016-g8bdf555-dirty #211
Call Trace:
dump_stack+0x4c/0x6e
mark_lock+0x384/0x56d
mark_held_locks+0x5f/0x76
lockdep_trace_alloc+0xb2/0xb5
kmem_cache_alloc_trace+0x32/0x1e2
zcomp_strm_alloc+0x25/0x73 [zram]
zcomp_strm_multi_find+0xe7/0x173 [zram]
zcomp_strm_find+0xc/0xe [zram]
zram_bvec_rw+0x2ca/0x7e0 [zram]
zram_make_request+0x1fa/0x301 [zram]
generic_make_request+0x9c/0xdb
submit_bio+0xf7/0x120
ext4_io_submit+0x2e/0x43
ext4_bio_write_page+0x1b7/0x300
mpage_submit_page+0x60/0x77
mpage_map_and_submit_buffers+0x10f/0x21d
ext4_writepages+0xc8c/0xe1b
do_writepages+0x23/0x2c
__filemap_fdatawrite_range+0x84/0x8b
filemap_flush+0x1c/0x1e
ext4_alloc_da_blocks+0xb8/0x117
ext4_rename+0x132/0x6dc
? mark_held_locks+0x5f/0x76
ext4_rename2+0x29/0x2b
vfs_rename+0x540/0x636
SyS_renameat2+0x359/0x44d
SyS_rename+0x1e/0x20
entry_SYSCALL_64_fastpath+0x12/0x6f--- drivers/block/zram/zcomp.c | 4 ++-- drivers/block/zram/zcomp_lz4.c | 2 +- drivers/block/zram/zcomp_lzo.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/block/zram/zcomp.c +2 -2
@@ -76,7 +76,7 @@ static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm)*/ static struct zcomp_strm *zcomp_strm_alloc (struct zcomp *comp) { -struct zcomp_strm *zstrm =kmalloc (sizeof (*zstrm),GFP_KERNEL ); +struct zcomp_strm *zstrm =kmalloc (sizeof (*zstrm),GFP_NOIO );if (!zstrm)return NULL ;
@@ -85,7 +85,7 @@ static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp)* allocate 2 pages. 1 for compressed data, plus 1 extra for the * case when compressed size is larger than the original one */ - zstrm->buffer = (void *)__get_free_pages (GFP_KERNEL | __GFP_ZERO,1 ); + zstrm->buffer = (void *)__get_free_pages (GFP_NOIO | __GFP_ZERO,1 );if (!zstrm->private || !zstrm->buffer) {zcomp_strm_free (comp, zstrm); zstrm =NULL ;
drivers/block/zram/zcomp_lz4.c +1 -1
@@ -15,7 +15,7 @@static void *zcomp_lz4_create (void ) { -return kzalloc (LZ4_MEM_COMPRESS ,GFP_KERNEL ); +return kzalloc (LZ4_MEM_COMPRESS ,GFP_NOIO ); }static void zcomp_lz4_destroy (void *private)
drivers/block/zram/zcomp_lzo.c +1 -1
@@ -15,7 +15,7 @@static void *lzo_create (void ) { -return kzalloc (LZO1X_MEM_COMPRESS ,GFP_KERNEL ); +return kzalloc (LZO1X_MEM_COMPRESS ,GFP_NOIO ); }static void lzo_destroy (void *private)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] perf kvm record/report: 'unprocessable sample' error while recording/reporting guest data
In reply to Sasha LevinFrom: Ravi Bangoria <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 3caeaa562733c4836e61086ec07666635006a787 ]
While recording guest samples in host using perf kvm record, it will populate unprocessable sample error, though samples will be recorded properly. While generating report using perf kvm report, no samples will be processed and same error will populate. We have seen this behaviour with upstream perf(4.4-rc3) on x86 and ppc64 hardware.
Reason behind this failure is, when it tries to fetch machine from rb_tree of machines, it fails. As a part of tracing a bug, we figured out that this code was incorrectly refactored in commit 54245fdc3576 ("perf session: Remove wrappers to machines__find").
This patch will change the functionality such that if it can't fetch machine in first trial, it will create one node of machine and add that to rb_tree. So next time when it tries to fetch same machine from rb_tree, it won't fail. Actually it was the case before refactoring of code in aforementioned commit.
This patch is generated from acme perf/core branch.
Below I've mention an example that demonstrate the behaviour before and after applying patch.
Before applying patch:
[Note: One needs to run guest before recording data in host]
ravi@ravi-bangoria:~$ ./perf kvm record -a Warning: 5903 unprocessable samples recorded. Do you have a KVM guest running and not using 'perf kvm'? [ perf record: Captured and wrote 1.409 MB perf.data.guest (285 samples) ]
ravi@ravi-bangoria:~$ ./perf kvm report --stdio Warning: 5903 unprocessable samples recorded. Do you have a KVM guest running and not using 'perf kvm'? # To display the perf.data header info, please use --header/--header-only options. # # Total Lost Samples: 0 # # Samples: 285 of event 'cycles' # Event count (approx.): 88715406 # # Overhead Command Shared Object Symbol # ........ ....... ............. ...... #
# (For a higher level overview, try: perf report --sort comm,dso) #
After applying patch:
ravi@ravi-bangoria:~$ ./perf kvm record -a [ perf record: Captured and wrote 1.188 MB perf.data.guest (17 samples) ]
ravi@ravi-bangoria:~$ ./perf kvm report --stdio
# To display the perf.data header info, please use --header/--header-only options.
#
# Total Lost Samples: 0
#
# Samples: 17 of event 'cycles'
# Event count (approx.): 700746
#
# Overhead Command Shared Object Symbol
# ........ ....... ................ ......................
#
34.19% :5758 [unknown] [g] 0xffffffff818682ab
22.79% :5758 [unknown] [g] 0xffffffff812dc7f8
22.79% :5758 [unknown] [g] 0xffffffff818650d0
14.83% :5758 [unknown] [g] 0xffffffff8161a1b6
2.49% :5758 [unknown] [g] 0xffffffff818692bf
0.48% :5758 [unknown] [g] 0xffffffff81869253
0.05% :5758 [unknown] [g] 0xffffffff81869250--- tools/perf/util/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/session.c +1 -1
@@ -816,7 +816,7 @@ static struct machine *machines__find_for_cpumode(struct machines *machines, machine =machines__find (machines, pid);if (!machine) - machine =machines__find (machines,DEFAULT_GUEST_KERNEL_ID ); + machine =machines__findnew (machines,DEFAULT_GUEST_KERNEL_ID );return machine; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] wlcore/wl12xx: spi: fix oops on firmware load
In reply to Sasha LevinFrom: Uri Mashiach <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9b2761cb72dc41e1948c8a5512b4efd384eda130 ]
The maximum chunks used by the function is (SPI_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE + 1).
The original commands array had space for (SPI_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE) commands. When the last chunk is used (len > 4 * WSPI_MAX_CHUNK_SIZE), the last command is stored outside the bounds of the commands array.
Oops 5 (page fault) is generated during current wl1271 firmware load attempt:
root@debian-armhf:~# ifconfig wlan0 up [ 294.312399] Unable to handle kernel paging request at virtual address 00203fc4 [ 294.320173] pgd = de528000 [ 294.323028] [00203fc4] *pgd=00000000 [ 294.326916] Internal error: Oops: 5 [#1] SMP ARM [ 294.331789] Modules linked in: bnep rfcomm bluetooth ipv6 arc4 wl12xx wlcore mac80211 musb_dsps cfg80211 musb_hdrc usbcore usb_common wlcore_spi omap_rng rng_core musb_am335x omap_wdt cpufreq_dt thermal_sys hwmon [ 294.351838] CPU: 0 PID: 1827 Comm: ifconfig Not tainted 4.2.0-00002-g3e9ad27-dirty #78 [ 294.360154] Hardware name: Generic AM33XX (Flattened Device Tree) [ 294.366557] task: dc9d6d40 ti: de550000 task.ti: de550000 [ 294.372236] PC is at __spi_validate+0xa8/0x2ac [ 294.376902] LR is at __spi_sync+0x78/0x210 [ 294.381200] pc : [<c049c760>] lr : [<c049ebe0>] psr: 60000013 [ 294.381200] sp : de551998 ip : de5519d8 fp : 00200000 [ 294.393242] r10: de551c8c r9 : de5519d8 r8 : de3a9000 [ 294.398730] r7 : de3a9258 r6 : de3a9400 r5 : de551a48 r4 : 00203fbc [ 294.405577] r3 : 00000000 r2 : 00000000 r1 : 00000000 r0 : de3a9000 [ 294.412420] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 294.419918] Control: 10c5387d Table: 9e528019 DAC: 00000015 [ 294.425954] Process ifconfig (pid: 1827, stack limit = 0xde550218) [ 294.432437] Stack: (0xde551998 to 0xde552000)
...
[ 294.883613] [<c049c760>] (__spi_validate) from [<c049ebe0>] (__spi_sync+0x78/0x210) [ 294.891670] [<c049ebe0>] (__spi_sync) from [<bf036598>] (wl12xx_spi_raw_write+0xfc/0x148 [wlcore_spi]) [ 294.901661] [<bf036598>] (wl12xx_spi_raw_write [wlcore_spi]) from [<bf21c694>] (wlcore_boot_upload_firmware+0x1ec/0x458 [wlcore]) [ 294.914038] [<bf21c694>] (wlcore_boot_upload_firmware [wlcore]) from [<bf24532c>] (wl12xx_boot+0xc10/0xfac [wl12xx]) [ 294.925161] [<bf24532c>] (wl12xx_boot [wl12xx]) from [<bf20d5cc>] (wl1271_op_add_interface+0x5b0/0x910 [wlcore]) [ 294.936364] [<bf20d5cc>] (wl1271_op_add_interface [wlcore]) from [<bf15c4ac>] (ieee80211_do_open+0x44c/0xf7c [mac80211]) [ 294.947963] [<bf15c4ac>] (ieee80211_do_open [mac80211]) from [<c0537978>] (__dev_open+0xa8/0x110) [ 294.957307] [<c0537978>] (__dev_open) from [<c0537bf8>] (__dev_change_flags+0x88/0x148) [ 294.965713] [<c0537bf8>] (__dev_change_flags) from [<c0537cd0>] (dev_change_flags+0x18/0x48) [ 294.974576] [<c0537cd0>] (dev_change_flags) from [<c05a55a0>] (devinet_ioctl+0x6b4/0x7d0) [ 294.983191] [<c05a55a0>] (devinet_ioctl) from [<c0517040>] (sock_ioctl+0x1e4/0x2bc) [ 294.991244] [<c0517040>] (sock_ioctl) from [<c017d378>] (do_vfs_ioctl+0x420/0x6b0) [ 294.999208] [<c017d378>] (do_vfs_ioctl) from [<c017d674>] (SyS_ioctl+0x6c/0x7c) [ 295.006880] [<c017d674>] (SyS_ioctl) from [<c000f4c0>] (ret_fast_syscall+0x0/0x54) [ 295.014835] Code: e1550004 e2444034 0a00007d e5953018 (e5942008) [ 295.021544] ---[ end trace 66ed188198f4e24e ]---
--- drivers/net/wireless/ti/wlcore/spi.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/ti/wlcore/spi.c +7 -3
@@ -73,7 +73,10 @@*/ #define SPI_AGGR_BUFFER_SIZE (4 * PAGE_SIZE) -#define WSPI_MAX_NUM_OF_CHUNKS (SPI_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE) +/* Maximum number of SPI write chunks */ +#define WSPI_MAX_NUM_OF_CHUNKS \ + ((SPI_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE) + 1) +struct wl12xx_spi_glue {struct device *dev;
@@ -268,9 +271,10 @@ static int __must_check wl12xx_spi_raw_write(struct device *child, int addr, void *buf, size_t len, bool fixed) {struct wl12xx_spi_glue *glue =dev_get_drvdata (child->parent); -struct spi_transfer t[2 * (WSPI_MAX_NUM_OF_CHUNKS +1 )]; +/* SPI write buffers - 2 for each chunk */ +struct spi_transfer t[2 *WSPI_MAX_NUM_OF_CHUNKS ];struct spi_message m; -u32 commands[WSPI_MAX_NUM_OF_CHUNKS ]; +u32 commands[WSPI_MAX_NUM_OF_CHUNKS ];/* 1 command per chunk */ u32 *cmd;u32 chunk_len;int i;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] PCI: host: Mark PCIe/PCI (MSI) IRQ cascade handlers as IRQF_NO_THREAD
In reply to Sasha LevinFrom: Grygorii Strashko <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8ff0ef996ca00028519c70e8d51d32bd37eb51dc ]
On -RT and if kernel is booting with "threadirqs" cmd line parameter, PCIe/PCI (MSI) IRQ cascade handlers (like dra7xx_pcie_msi_irq_handler()) will be forced threaded and, as result, will generate warnings like this:
WARNING: CPU: 1 PID: 82 at kernel/irq/handle.c:150 handle_irq_event_percpu+0x14c/0x174() irq 460 handler irq_default_primary_handler+0x0/0x14 enabled interrupts Backtrace: (warn_slowpath_common) from (warn_slowpath_fmt+0x38/0x40) (warn_slowpath_fmt) from (handle_irq_event_percpu+0x14c/0x174) (handle_irq_event_percpu) from (handle_irq_event+0x84/0xb8) (handle_irq_event) from (handle_simple_irq+0x90/0x118) (handle_simple_irq) from (generic_handle_irq+0x30/0x44) (generic_handle_irq) from (dra7xx_pcie_msi_irq_handler+0x7c/0x8c) (dra7xx_pcie_msi_irq_handler) from (irq_forced_thread_fn+0x28/0x5c) (irq_forced_thread_fn) from (irq_thread+0x128/0x204)
This happens because all of them invoke generic_handle_irq() from the requested handler. generic_handle_irq() grabs raw_locks and thus needs to run in raw-IRQ context.
This issue was originally reproduced on TI dra7-evem, but, as was identified during discussion [1], other hosts can also suffer from this issue. Fix all them at once by marking PCIe/PCI (MSI) IRQ cascade handlers IRQF_NO_THREAD explicitly.
[1] http://lkml.kernel.org/r/[email protected]
--- drivers/pci/host/pci-dra7xx.c | 3 ++- drivers/pci/host/pci-exynos.c | 3 ++- drivers/pci/host/pci-imx6.c | 3 ++- drivers/pci/host/pci-tegra.c | 2 +- drivers/pci/host/pcie-rcar.c | 6 ++++-- drivers/pci/host/pcie-spear13xx.c | 3 ++- drivers/pci/host/pcie-xilinx.c | 3 ++- 7 files changed, 15 insertions(+), 8 deletions(-)
drivers/pci/host/pci-dra7xx.c +2 -1
@@ -289,7 +289,8 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx, } ret =devm_request_irq (&pdev->dev, pp->irq, - dra7xx_pcie_msi_irq_handler,IRQF_SHARED , + dra7xx_pcie_msi_irq_handler, +IRQF_SHARED |IRQF_NO_THREAD ,"dra7-pcie-msi" , pp);if (ret) {dev_err (&pdev->dev,"failed to request irq\n" );
drivers/pci/host/pci-exynos.c +2 -1
@@ -527,7 +527,8 @@ static int __init exynos_add_pcie_port(struct pcie_port *pp, ret =devm_request_irq (&pdev->dev, pp->msi_irq, exynos_pcie_msi_irq_handler, -IRQF_SHARED ,"exynos-pcie" , pp); +IRQF_SHARED |IRQF_NO_THREAD , +"exynos-pcie" , pp);if (ret) {dev_err (&pdev->dev,"failed to request msi irq\n" );return ret;
drivers/pci/host/pci-imx6.c +2 -1
@@ -534,7 +534,8 @@ static int __init imx6_add_pcie_port(struct pcie_port *pp, ret =devm_request_irq (&pdev->dev, pp->msi_irq, imx6_pcie_msi_handler, -IRQF_SHARED ,"mx6-pcie-msi" , pp); +IRQF_SHARED |IRQF_NO_THREAD , +"mx6-pcie-msi" , pp);if (ret) {dev_err (&pdev->dev,"failed to request MSI irq\n" );return -ENODEV ;
drivers/pci/host/pci-tegra.c +1 -1
@@ -1304,7 +1304,7 @@ static int tegra_pcie_enable_msi(struct tegra_pcie *pcie) msi->irq = err; - err =request_irq (msi->irq, tegra_pcie_msi_irq,0 , + err =request_irq (msi->irq, tegra_pcie_msi_irq,IRQF_NO_THREAD , tegra_msi_irq_chip.name, pcie);if (err <0 ) {dev_err (&pdev->dev,"failed to request IRQ: %d\n" , err);
drivers/pci/host/pcie-rcar.c +4 -2
@@ -695,14 +695,16 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)/* Two irqs are for MSI, but they are also used for non-MSI irqs */ err =devm_request_irq (&pdev->dev, msi->irq1, rcar_pcie_msi_irq, -IRQF_SHARED , rcar_msi_irq_chip.name, pcie); +IRQF_SHARED |IRQF_NO_THREAD , + rcar_msi_irq_chip.name, pcie);if (err <0 ) {dev_err (&pdev->dev,"failed to request IRQ: %d\n" , err); goto err; } err =devm_request_irq (&pdev->dev, msi->irq2, rcar_pcie_msi_irq, -IRQF_SHARED , rcar_msi_irq_chip.name, pcie); +IRQF_SHARED |IRQF_NO_THREAD , + rcar_msi_irq_chip.name, pcie);if (err <0 ) {dev_err (&pdev->dev,"failed to request IRQ: %d\n" , err); goto err;
drivers/pci/host/pcie-spear13xx.c +2 -1
@@ -281,7 +281,8 @@ static int spear13xx_add_pcie_port(struct pcie_port *pp,return -ENODEV ; } ret =devm_request_irq (dev, pp->irq, spear13xx_pcie_irq_handler, -IRQF_SHARED ,"spear1340-pcie" , pp); +IRQF_SHARED |IRQF_NO_THREAD , +"spear1340-pcie" , pp);if (ret) {dev_err (dev,"failed to request irq %d\n" , pp->irq);return ret;
drivers/pci/host/pcie-xilinx.c +2 -1
@@ -776,7 +776,8 @@ static int xilinx_pcie_parse_dt(struct xilinx_pcie_port *port) port->irq =irq_of_parse_and_map (node,0 ); err =devm_request_irq (dev, port->irq, xilinx_pcie_intr_handler, -IRQF_SHARED ,"xilinx-pcie" , port); +IRQF_SHARED |IRQF_NO_THREAD , +"xilinx-pcie" , port);if (err) {dev_err (dev,"unable to request irq %d\n" , port->irq);return err;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] memcg: only free spare array when readers are done
In reply to Sasha LevinFrom: Martijn Coenen <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6611d8d76132f86faa501de9451a89bf23fb2371 ]
A spare array holding mem cgroup threshold events is kept around to make sure we can always safely deregister an event and have an array to store the new set of events in.
In the scenario where we're going from 1 to 0 registered events, the pointer to the primary array containing 1 event is copied to the spare slot, and then the spare slot is freed because no events are left. However, it is freed before calling synchronize_rcu(), which means readers may still be accessing threshold->primary after it is freed.
Fixed by only freeing after synchronize_rcu().
--- mm/memcontrol.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
mm/memcontrol.c +6 -5
@@ -3824,16 +3824,17 @@ static void __mem_cgroup_usage_unregister_event(struct mem_cgroup *memcg, swap_buffers:/* Swap primary and spare array */ thresholds->spare = thresholds->primary; -/* If all events are unregistered, free the spare array */ -if (!new) { -kfree (thresholds->spare); - thresholds->spare =NULL ; - }rcu_assign_pointer (thresholds->primary, new);/* To be sure that nobody uses thresholds */ synchronize_rcu (); + +/* If all events are unregistered, free the spare array */ +if (!new) { +kfree (thresholds->spare); + thresholds->spare =NULL ; + } unlock:mutex_unlock (&memcg->thresholds_lock); }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] crypto: af_alg - Disallow bind/setkey/... after accept(2)
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c840ac6af3f8713a71b4d2363419145760bd6044 ]
Each af_alg parent socket obtained by socket(2) corresponds to a tfm object once bind(2) has succeeded. An accept(2) call on that parent socket creates a context which then uses the tfm object.
Therefore as long as any child sockets created by accept(2) exist the parent socket must not be modified or freed.
This patch guarantees this by using locks and a reference count on the parent socket. Any attempt to modify the parent socket will fail with EBUSY.
--- crypto/af_alg.c | 35 ++++++++++++++++++++++++++++++++--- include/crypto/if_alg.h | 8 +++----- 2 files changed, 35 insertions(+), 8 deletions(-)
crypto/af_alg.c +32 -3
@@ -125,6 +125,23 @@ int af_alg_release(struct socket *sock) }EXPORT_SYMBOL_GPL (af_alg_release); +void af_alg_release_parent (struct sock *sk) +{ +struct alg_sock *ask =alg_sk (sk); +bool last; + + sk = ask->parent; + ask =alg_sk (sk); + +lock_sock (sk); + last = !--ask->refcnt; +release_sock (sk); + +if (last) +sock_put (sk); +} +EXPORT_SYMBOL_GPL (af_alg_release_parent); +static int alg_bind (struct socket *sock,struct sockaddr *uaddr,int addr_len) {struct sock *sk = sock->sk;
@@ -132,6 +149,7 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)struct sockaddr_alg *sa = (void *)uaddr;const struct af_alg_type *type;void *private; +int err;if (sock->state ==SS_CONNECTED )return -EINVAL ;
@@ -157,16 +175,22 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)return PTR_ERR (private); } + err = -EBUSY ;lock_sock (sk); +if (ask->refcnt) + goto unlock;swap (ask->type, type);swap (ask->private, private); + err =0 ; + +unlock:release_sock (sk);alg_do_release (type, private); -return 0 ; +return err; } static int alg_setkey(struct sock *sk, char __user *ukey,
@@ -199,11 +223,15 @@ static int alg_setsockopt(struct socket *sock, int level, int optname,struct sock *sk = sock->sk;struct alg_sock *ask =alg_sk (sk);const struct af_alg_type *type; -int err = -ENOPROTOOPT ; +int err = -EBUSY ;lock_sock (sk); +if (ask->refcnt) + goto unlock; + type = ask->type; + err = -ENOPROTOOPT ;if (level !=SOL_ALG || !type) goto unlock;
@@ -261,7 +289,8 @@ int af_alg_accept(struct sock *sk, struct socket *newsock) sk2->sk_family =PF_ALG ; -sock_hold (sk); +if (!ask->refcnt++) +sock_hold (sk);alg_sk (sk2)->parent = sk;alg_sk (sk2)->type = type;
include/crypto/if_alg.h +3 -5
@@ -30,6 +30,8 @@ struct alg_sock {struct sock *parent; +unsigned int refcnt; +const struct af_alg_type *type;void *private; };
@@ -67,6 +69,7 @@ int af_alg_register_type(const struct af_alg_type *type);int af_alg_unregister_type (const struct af_alg_type *type);int af_alg_release (struct socket *sock); +void af_alg_release_parent (struct sock *sk);int af_alg_accept (struct sock *sk,struct socket *newsock);int af_alg_make_sg (struct af_alg_sgl *sgl,struct iov_iter *iter,int len);
@@ -83,11 +86,6 @@ static inline struct alg_sock *alg_sk(struct sock *sk)return (struct alg_sock *)sk; } -static inline void af_alg_release_parent (struct sock *sk) -{ -sock_put (alg_sk (sk)->parent); -} -static inline void af_alg_init_completion (struct af_alg_completion *completion) {init_completion (&completion->completion);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] drm/i915: Restore inhibiting the load of the default context
In reply to Sasha LevinFrom: Chris Wilson <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 06ef83a705a98da63797a5a570220b6ca36febd4 ]
Following a GPU reset, we may leave the context in a poorly defined state, and reloading from that context will leave the GPU flummoxed. For secondary contexts, this will lead to that context being banned - but currently it is also causing the default context to become banned, leading to turmoil in the shared state.
This is a regression from
commit 6702cf16e0ba8b0129f5aa1b6609d4e9c70bc13b [v4.1]
Author: Ben Widawsky <[email protected]> Date: Mon Mar 16 16:00:58 2015 +0000
drm/i915: Initialize all contexts
which quietly introduced the removal of the MI_RESTORE_INHIBIT on the default context.
v2: Mark the global default context as uninitialized on GPU reset so that the context-local workarounds are reloaded upon re-enabling.
[danvet: This seems to fix a gpu hand on after the first resume, resulting in any future suspend operation failing with -EIO because the gpu seems to be in a funky state. Somehow this patch fixes that.]
--- drivers/gpu/drm/i915/i915_gem_context.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_context.c +5 -1
@@ -317,6 +317,10 @@ void i915_gem_context_reset(struct drm_device *dev)i915_gem_context_unreference (lctx); ring->last_context =NULL ; } + +/* Force the GPU state to be reinitialised on enabling */ +if (ring->default_context) + ring->default_context->legacy_hw_ctx.initialized = false; } }
@@ -704,7 +708,7 @@ static int do_switch(struct intel_engine_cs *ring, goto unpin_out; } -if (!to->legacy_hw_ctx.initialized) { +if (!to->legacy_hw_ctx.initialized ||i915_gem_context_is_default (to)) { hw_flags |=MI_RESTORE_INHIBIT ;/* NB: If we inhibit the restore, the context is not allowed to * die because future work may end up depending on valid address
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] zram: try vmalloc() after kmalloc()
In reply to Sasha LevinFrom: Kyeongdon Kim <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d913897abace843bba20249f3190167f7895e9c3 ]
When we're using LZ4 multi compression streams for zram swap, we found out page allocation failure message in system running test. That was not only once, but a few(2 - 5 times per test). Also, some failure cases were continually occurring to try allocation order 3.
In order to make parallel compression private data, we should call kzalloc() with order 2/3 in runtime(lzo/lz4). But if there is no order 2/3 size memory to allocate in that time, page allocation fails. This patch makes to use vmalloc() as fallback of kmalloc(), this prevents page alloc failure warning.
After using this, we never found warning message in running test, also It could reduce process startup latency about 60-120ms in each case.
For reference a call trace :
Binder_1: page allocation failure: order:3, mode:0x10c0d0
CPU: 0 PID: 424 Comm: Binder_1 Tainted: GW 3.10.49-perf-g991d02b-dirty #20
Call trace:
dump_backtrace+0x0/0x270
show_stack+0x10/0x1c
dump_stack+0x1c/0x28
warn_alloc_failed+0xfc/0x11c
__alloc_pages_nodemask+0x724/0x7f0
__get_free_pages+0x14/0x5c
kmalloc_order_trace+0x38/0xd8
zcomp_lz4_create+0x2c/0x38
zcomp_strm_alloc+0x34/0x78
zcomp_strm_multi_find+0x124/0x1ec
zcomp_strm_find+0xc/0x18
zram_bvec_rw+0x2fc/0x780
zram_make_request+0x25c/0x2d4
generic_make_request+0x80/0xbc
submit_bio+0xa4/0x15c
__swap_writepage+0x218/0x230
swap_writepage+0x3c/0x4c
shrink_page_list+0x51c/0x8d0
shrink_inactive_list+0x3f8/0x60c
shrink_lruvec+0x33c/0x4cc
shrink_zone+0x3c/0x100
try_to_free_pages+0x2b8/0x54c
__alloc_pages_nodemask+0x514/0x7f0
__get_free_pages+0x14/0x5c
proc_info_read+0x50/0xe4
vfs_read+0xa0/0x12c
SyS_read+0x44/0x74
DMA: 3397*4kB (MC) 26*8kB (RC) 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB
0*512kB 0*1024kB 0*2048kB 0*4096kB = 13796kBSergey Senozhatsky <[email protected]>
--- drivers/block/zram/zcomp_lz4.c | 23 +++++++++++++++++++++-- drivers/block/zram/zcomp_lzo.c | 23 +++++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-)
drivers/block/zram/zcomp_lz4.c +21 -2
@@ -10,17 +10,36 @@#include <linux/kernel.h> #include <linux/slab.h> #include <linux/lz4.h> +#include <linux/vmalloc.h> +#include <linux/mm.h> #include "zcomp_lz4.h" static void *zcomp_lz4_create (void ) { -return kzalloc (LZ4_MEM_COMPRESS ,GFP_NOIO ); +void *ret; + +/* +* This function can be called in swapout/fs write path +* so we can't use GFP_FS|IO. And it assumes we already +* have at least one stream in zram initialization so we +* don't do best effort to allocate more stream in here. +* A default stream will work well without further multiple +* streams. That's why we use NORETRY | NOWARN. +*/ + ret =kzalloc (LZ4_MEM_COMPRESS ,GFP_NOIO | __GFP_NORETRY | + __GFP_NOWARN); +if (!ret) + ret =__vmalloc (LZ4_MEM_COMPRESS , +GFP_NOIO | __GFP_NORETRY | __GFP_NOWARN | + __GFP_ZERO | __GFP_HIGHMEM, +PAGE_KERNEL ); +return ret; }static void zcomp_lz4_destroy (void *private) { -kfree (private); +kvfree (private); } static int zcomp_lz4_compress(const unsigned char *src, unsigned char *dst,
drivers/block/zram/zcomp_lzo.c +21 -2
@@ -10,17 +10,36 @@#include <linux/kernel.h> #include <linux/slab.h> #include <linux/lzo.h> +#include <linux/vmalloc.h> +#include <linux/mm.h> #include "zcomp_lzo.h" static void *lzo_create (void ) { -return kzalloc (LZO1X_MEM_COMPRESS ,GFP_NOIO ); +void *ret; + +/* +* This function can be called in swapout/fs write path +* so we can't use GFP_FS|IO. And it assumes we already +* have at least one stream in zram initialization so we +* don't do best effort to allocate more stream in here. +* A default stream will work well without further multiple +* streams. That's why we use NORETRY | NOWARN. +*/ + ret =kzalloc (LZO1X_MEM_COMPRESS ,GFP_NOIO | __GFP_NORETRY | + __GFP_NOWARN); +if (!ret) + ret =__vmalloc (LZO1X_MEM_COMPRESS , +GFP_NOIO | __GFP_NORETRY | __GFP_NOWARN | + __GFP_ZERO | __GFP_HIGHMEM, +PAGE_KERNEL ); +return ret; }static void lzo_destroy (void *private) { -kfree (private); +kvfree (private); } static int lzo_compress(const unsigned char *src, unsigned char *dst,
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] crypto: af_alg - Fix socket double-free when accept fails
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a383292c86663bbc31ac62cc0c04fc77504636a6 ]
When we fail an accept(2) call we will end up freeing the socket twice, once due to the direct sk_free call and once again through newsock.
This patch fixes this by removing the sk_free call.
--- crypto/af_alg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
crypto/af_alg.c +1 -3
@@ -282,10 +282,8 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)security_sk_clone (sk, sk2); err = type->accept (ask->private, sk2); -if (err) { -sk_free (sk2); +if (err) goto unlock; - } sk2->sk_family =PF_ALG ;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] crypto: af_alg - Add nokey compatibility path
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 37766586c965d63758ad542325a96d5384f4a8c9 ]
This patch adds a compatibility path to support old applications that do acept(2) before setkey.
--- crypto/af_alg.c | 13 ++++++++++++- include/crypto/if_alg.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-)
crypto/af_alg.c +12 -1
@@ -76,6 +76,8 @@ int af_alg_register_type(const struct af_alg_type *type) goto unlock; type->ops->owner =THIS_MODULE ; +if (type->ops_nokey) + type->ops_nokey->owner =THIS_MODULE ; node->type = type;list_add (&node->list, &alg_types); err =0 ;
@@ -264,6 +266,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)const struct af_alg_type *type;struct sock *sk2;int err; +bool nokey;lock_sock (sk); type = ask->type;
@@ -282,12 +285,17 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)security_sk_clone (sk, sk2); err = type->accept (ask->private, sk2); + + nokey = err == -ENOKEY ; +if (nokey && type->accept_nokey) + err = type->accept_nokey (ask->private, sk2); +if (err) goto unlock; sk2->sk_family =PF_ALG ; -if (!ask->refcnt++) +if (nokey || !ask->refcnt++)sock_hold (sk);alg_sk (sk2)->parent = sk;alg_sk (sk2)->type = type;
@@ -295,6 +303,9 @@ int af_alg_accept(struct sock *sk, struct socket *newsock) newsock->ops = type->ops; newsock->state =SS_CONNECTED ; +if (nokey) + newsock->ops = type->ops_nokey; + err =0 ; unlock:
include/crypto/if_alg.h +2 -0
@@ -52,9 +52,11 @@ struct af_alg_type {void (*release)(void *private);int (*setkey)(void *private,const u8 *key,unsigned int keylen);int (*accept)(void *private,struct sock *sk); +int (*accept_nokey)(void *private,struct sock *sk);int (*setauthsize)(void *private,unsigned int authsize);struct proto_ops *ops; +struct proto_ops *ops_nokey;struct module *owner;char name[14 ]; };
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] crypto: algif_hash - Require setkey before accept(2)
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6de62f15b581f920ade22d758f4c338311c2f0d4 ]
Hash implementations that require a key may crash if you use them without setting a key. This patch adds the necessary checks so that if you do attempt to use them without a key that we return -ENOKEY instead of proceeding.
This patch also adds a compatibility path to support old applications that do acept(2) before setkey.
--- crypto/algif_hash.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 193 insertions(+), 8 deletions(-)
crypto/algif_hash.c +193 -8
@@ -34,6 +34,11 @@ struct hash_ctx {struct ahash_request req; }; +struct algif_hash_tfm { +struct crypto_ahash *hash; +bool has_key; +}; +static int hash_sendmsg (struct socket *sock,struct msghdr *msg,size_t ignored) {
@@ -227,22 +232,151 @@ static struct proto_ops algif_hash_ops = { .accept = hash_accept, }; +static int hash_check_key (struct socket *sock) +{ +int err; +struct sock *psk; +struct alg_sock *pask; +struct algif_hash_tfm *tfm; +struct sock *sk = sock->sk; +struct alg_sock *ask =alg_sk (sk); + +if (ask->refcnt) +return 0 ; + + psk = ask->parent; + pask =alg_sk (ask->parent); + tfm = pask->private; + + err = -ENOKEY ; +lock_sock (psk); +if (!tfm->has_key) + goto unlock; + +if (!pask->refcnt++) +sock_hold (psk); + + ask->refcnt =1 ; +sock_put (psk); + + err =0 ; + +unlock: +release_sock (psk); + +return err; +} + +static int hash_sendmsg_nokey (struct socket *sock,struct msghdr *msg, +size_t size) +{ +int err; + + err =hash_check_key (sock); +if (err) +return err; + +return hash_sendmsg (sock, msg, size); +} + +static ssize_t hash_sendpage_nokey (struct socket *sock,struct page *page, +int offset,size_t size,int flags) +{ +int err; + + err =hash_check_key (sock); +if (err) +return err; + +return hash_sendpage (sock, page, offset, size, flags); +} + +static int hash_recvmsg_nokey (struct socket *sock,struct msghdr *msg, +size_t ignored,int flags) +{ +int err; + + err =hash_check_key (sock); +if (err) +return err; + +return hash_recvmsg (sock, msg, ignored, flags); +} + +static int hash_accept_nokey (struct socket *sock,struct socket *newsock, +int flags) +{ +int err; + + err =hash_check_key (sock); +if (err) +return err; + +return hash_accept (sock, newsock, flags); +} + +static struct proto_ops algif_hash_ops_nokey = { + .family =PF_ALG , + + .connect = sock_no_connect, + .socketpair = sock_no_socketpair, + .getname = sock_no_getname, + .ioctl = sock_no_ioctl, + .listen = sock_no_listen, + .shutdown = sock_no_shutdown, + .getsockopt = sock_no_getsockopt, + .mmap = sock_no_mmap, + .bind = sock_no_bind, + .setsockopt = sock_no_setsockopt, + .poll = sock_no_poll, + + .release = af_alg_release, + .sendmsg = hash_sendmsg_nokey, + .sendpage = hash_sendpage_nokey, + .recvmsg = hash_recvmsg_nokey, + .accept = hash_accept_nokey, +}; +static void *hash_bind (const char *name,u32 type,u32 mask) { -return crypto_alloc_ahash (name, type, mask); +struct algif_hash_tfm *tfm; +struct crypto_ahash *hash; + + tfm =kzalloc (sizeof (*tfm),GFP_KERNEL ); +if (!tfm) +return ERR_PTR (-ENOMEM ); + + hash =crypto_alloc_ahash (name, type, mask); +if (IS_ERR (hash)) { +kfree (tfm); +return ERR_CAST (hash); + } + + tfm->hash = hash; + +return tfm; }static void hash_release (void *private) { -crypto_free_ahash (private); +struct algif_hash_tfm *tfm = private; + +crypto_free_ahash (tfm->hash); +kfree (tfm); }static int hash_setkey (void *private,const u8 *key,unsigned int keylen) { -return crypto_ahash_setkey (private, key, keylen); +struct algif_hash_tfm *tfm = private; +int err; + + err =crypto_ahash_setkey (tfm->hash, key, keylen); + tfm->has_key = !err; + +return err; } -static void hash_sock_destruct (struct sock *sk) +static void hash_sock_destruct_common (struct sock *sk) {struct alg_sock *ask =alg_sk (sk);struct hash_ctx *ctx = ask->private;
@@ -250,15 +384,40 @@ static void hash_sock_destruct(struct sock *sk)sock_kzfree_s (sk, ctx->result,crypto_ahash_digestsize (crypto_ahash_reqtfm (&ctx->req)));sock_kfree_s (sk, ctx, ctx->len); +} + +static void hash_sock_destruct (struct sock *sk) +{ +hash_sock_destruct_common (sk);af_alg_release_parent (sk); } -static int hash_accept_parent (void *private,struct sock *sk) +static void hash_release_parent_nokey (struct sock *sk) +{ +struct alg_sock *ask =alg_sk (sk); + +if (!ask->refcnt) { +sock_put (ask->parent); +return ; + } + +af_alg_release_parent (sk); +} + +static void hash_sock_destruct_nokey (struct sock *sk) +{ +hash_sock_destruct_common (sk); +hash_release_parent_nokey (sk); +} + +static int hash_accept_parent_common (void *private,struct sock *sk) {struct hash_ctx *ctx;struct alg_sock *ask =alg_sk (sk); -unsigned len =sizeof (*ctx) +crypto_ahash_reqsize (private); -unsigned ds =crypto_ahash_digestsize (private); +struct algif_hash_tfm *tfm = private; +struct crypto_ahash *hash = tfm->hash; +unsigned len =sizeof (*ctx) +crypto_ahash_reqsize (hash); +unsigned ds =crypto_ahash_digestsize (hash); ctx =sock_kmalloc (sk, len,GFP_KERNEL );if (!ctx)
@@ -278,7 +437,7 @@ static int hash_accept_parent(void *private, struct sock *sk) ask->private = ctx; -ahash_request_set_tfm (&ctx->req, private); +ahash_request_set_tfm (&ctx->req, hash);ahash_request_set_callback (&ctx->req,CRYPTO_TFM_REQ_MAY_BACKLOG , af_alg_complete, &ctx->completion);
@@ -287,12 +446,38 @@ static int hash_accept_parent(void *private, struct sock *sk)return 0 ; } +static int hash_accept_parent (void *private,struct sock *sk) +{ +struct algif_hash_tfm *tfm = private; + +if (!tfm->has_key &&crypto_ahash_has_setkey (tfm->hash)) +return -ENOKEY ; + +return hash_accept_parent_common (private, sk); +} + +static int hash_accept_parent_nokey (void *private,struct sock *sk) +{ +int err; + + err =hash_accept_parent_common (private, sk); +if (err) + goto out; + + sk->sk_destruct = hash_sock_destruct_nokey; + +out: +return err; +} +static const struct af_alg_type algif_type_hash = { .bind = hash_bind, .release = hash_release, .setkey = hash_setkey, .accept = hash_accept_parent, + .accept_nokey = hash_accept_parent_nokey, .ops = &algif_hash_ops, + .ops_nokey = &algif_hash_ops_nokey, .name ="hash" , .owner =THIS_MODULE };
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] crypto: hash - Add crypto_ahash_has_setkey
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a5596d6332787fd383b3b5427b41f94254430827 ]
This patch adds a way for ahash users to determine whether a key is required by a crypto_ahash transform.
--- crypto/ahash.c | 5 ++++- crypto/shash.c | 4 +++- include/crypto/hash.h | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-)
crypto/ahash.c +4 -1
@@ -451,6 +451,7 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)struct ahash_alg *alg =crypto_ahash_alg (hash); hash->setkey = ahash_nosetkey; + hash->has_setkey = false; hash->export = ahash_no_export; hash->import = ahash_no_import;
@@ -463,8 +464,10 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm) hash->finup = alg->finup ?: ahash_def_finup; hash->digest = alg->digest; -if (alg->setkey) +if (alg->setkey) { hash->setkey = alg->setkey; + hash->has_setkey = true; + }if (alg->export) hash->export = alg->export;if (alg->import)
crypto/shash.c +3 -1
@@ -355,8 +355,10 @@ int crypto_init_shash_ops_async(struct crypto_tfm *tfm) crt->finup = shash_async_finup; crt->digest = shash_async_digest; -if (alg->setkey) +if (alg->setkey) { crt->setkey = shash_async_setkey; + crt->has_setkey = true; + }if (alg->export) crt->export = shash_async_export;if (alg->import)
include/crypto/hash.h +6 -0
@@ -199,6 +199,7 @@ struct crypto_ahash { unsigned int keylen);unsigned int reqsize; +bool has_setkey;struct crypto_tfm base; };
@@ -356,6 +357,11 @@ static inline void *ahash_request_ctx(struct ahash_request *req)int crypto_ahash_setkey (struct crypto_ahash *tfm,const u8 *key,unsigned int keylen); +static inline bool crypto_ahash_has_setkey (struct crypto_ahash *tfm) +{ +return tfm->has_setkey; +} +/** * crypto_ahash_finup() - update and finalize message digest * @req: reference to the ahash_request handle that holds all information
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] printk: do cond_resched() between lines while outputting to consoles
In reply to Sasha LevinFrom: Tejun Heo <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8d91f8b15361dfb438ab6eb3b319e2ded43458ff ]
@console_may_schedule tracks whether console_sem was acquired through lock or trylock. If the former, we're inside a sleepable context and console_conditional_schedule() performs cond_resched(). This allows console drivers which use console_lock for synchronization to yield while performing time-consuming operations such as scrolling.
However, the actual console outputting is performed while holding irq-safe logbuf_lock, so console_unlock() clears @console_may_schedule before starting outputting lines. Also, only a few drivers call console_conditional_schedule() to begin with. This means that when a lot of lines need to be output by console_unlock(), for example on a console registration, the task doing console_unlock() may not yield for a long time on a non-preemptible kernel.
If this happens with a slow console devices, for example a serial console, the outputting task may occupy the cpu for a very long time. Long enough to trigger softlockup and/or RCU stall warnings, which in turn pile more messages, sometimes enough to trigger the next cycle of warnings incapacitating the system.
Fix it by making console_unlock() insert cond_resched() between lines if @console_may_schedule.
--- include/linux/console.h | 1 + kernel/panic.c | 3 +-- kernel/printk/printk.c | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-)
include/linux/console.h +1 -0
@@ -149,6 +149,7 @@ extern int console_trylock(void);extern void console_unlock (void );extern void console_conditional_schedule (void );extern void console_unblank (void ); +extern void console_flush_on_panic (void );extern struct tty_driver *console_device (int *);extern void console_stop (struct console *);extern void console_start (struct console *);
kernel/panic.c +1 -2
@@ -156,8 +156,7 @@ void panic(const char *fmt, ...)* panic() is not being callled from OOPS. */ debug_locks_off (); -console_trylock (); -console_unlock (); +console_flush_on_panic ();if (!panic_blink) panic_blink = no_blink;
kernel/printk/printk.c +34 -1
@@ -2173,13 +2173,24 @@ void console_unlock(void)static u64 seen_seq;unsigned long flags;bool wake_klogd = false; -bool retry; +bool do_cond_resched, retry;if (console_suspended) {up_console_sem ();return ; } +/* +* Console drivers are called under logbuf_lock, so +* @console_may_schedule should be cleared before; however, we may +* end up dumping a lot of lines, for example, if called from +* console registration path, and should invoke cond_resched() +* between lines if allowable. Not doing so can cause a very long +* scheduling stall on a slow console leading to RCU stall and +* softlockup warnings which exacerbate the issue with more +* messages practically incapacitating the system. +*/ + do_cond_resched = console_may_schedule; console_may_schedule =0 ;/* flush buffered message fragment immediately to console */
@@ -2241,6 +2252,9 @@ skip:call_console_drivers (level, text, len);start_critical_timings ();local_irq_restore (flags); + +if (do_cond_resched) +cond_resched (); } console_locked =0 ;
@@ -2308,6 +2322,25 @@ void console_unblank(void)console_unlock (); } +/** +* console_flush_on_panic - flush console content on panic +* +* Immediately output all pending messages no matter what. +*/ +void console_flush_on_panic (void ) +{ +/* +* If someone else is holding the console lock, trylock will fail +* and may_schedule may be set. Ignore and proceed to unlock so +* that messages are flushed out. As this can be called from any +* context and we don't want to get preempted while flushing, +* ensure may_schedule is cleared. +*/ +console_trylock (); + console_may_schedule =0 ; +console_unlock (); +} +/* * Return the console tty driver structure and its associated index */
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] crypto: af_alg - Allow af_af_alg_release_parent to be called on nokey path
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6a935170a980024dd29199e9dbb5c4da4767a1b9 ]
This patch allows af_alg_release_parent to be called even for nokey sockets.
--- crypto/af_alg.c | 9 ++++++++- include/crypto/if_alg.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-)
crypto/af_alg.c +8 -1
@@ -133,6 +133,12 @@ void af_alg_release_parent(struct sock *sk)bool last; sk = ask->parent; + +if (ask->nokey_refcnt && !ask->refcnt) { +sock_put (sk); +return ; + } + ask =alg_sk (sk);lock_sock (sk);
@@ -265,8 +271,8 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)struct alg_sock *ask =alg_sk (sk);const struct af_alg_type *type;struct sock *sk2; +unsigned int nokey;int err; -bool nokey;lock_sock (sk); type = ask->type;
@@ -299,6 +305,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)sock_hold (sk);alg_sk (sk2)->parent = sk;alg_sk (sk2)->type = type; +alg_sk (sk2)->nokey_refcnt = nokey; newsock->ops = type->ops; newsock->state =SS_CONNECTED ;
include/crypto/if_alg.h +1 -0
@@ -31,6 +31,7 @@ struct alg_sock {struct sock *parent;unsigned int refcnt; +unsigned int nokey_refcnt;const struct af_alg_type *type;void *private;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] crypto: af_alg - Forbid bind(2) when nokey child sockets are present
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a6a48c565f6f112c6983e2a02b1602189ed6e26e ]
This patch forbids the calling of bind(2) when there are child sockets created by accept(2) in existence, even if they are created on the nokey path.
This is needed as those child sockets have references to the tfm object which bind(2) will destroy.
--- crypto/af_alg.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
crypto/af_alg.c +7 -9
@@ -130,19 +130,16 @@ EXPORT_SYMBOL_GPL(af_alg_release);void af_alg_release_parent (struct sock *sk) {struct alg_sock *ask =alg_sk (sk); -bool last; +unsigned int nokey = ask->nokey_refcnt; +bool last = nokey && !ask->refcnt; sk = ask->parent; - -if (ask->nokey_refcnt && !ask->refcnt) { -sock_put (sk); -return ; - } - ask =alg_sk (sk);lock_sock (sk); - last = !--ask->refcnt; + ask->nokey_refcnt -= nokey; +if (!last) + last = !--ask->refcnt;release_sock (sk);if (last)
@@ -185,7 +182,7 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) err = -EBUSY ;lock_sock (sk); -if (ask->refcnt) +if (ask->refcnt | ask->nokey_refcnt) goto unlock;swap (ask->type, type);
@@ -303,6 +300,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)if (nokey || !ask->refcnt++)sock_hold (sk); + ask->nokey_refcnt += nokey;alg_sk (sk2)->parent = sk;alg_sk (sk2)->type = type;alg_sk (sk2)->nokey_refcnt = nokey;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] crypto: algif_hash - Fix race condition in hash_check_key
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ad46d7e33219218605ea619e32553daf4f346b9f ]
We need to lock the child socket in hash_check_key as otherwise two simultaneous calls can cause the parent socket to be freed.
--- crypto/algif_hash.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
crypto/algif_hash.c +6 -3
@@ -234,22 +234,23 @@ static struct proto_ops algif_hash_ops = {static int hash_check_key (struct socket *sock) { -int err; +int err =0 ;struct sock *psk;struct alg_sock *pask;struct algif_hash_tfm *tfm;struct sock *sk = sock->sk;struct alg_sock *ask =alg_sk (sk); +lock_sock (sk);if (ask->refcnt) -return 0 ; + goto unlock_child; psk = ask->parent; pask =alg_sk (ask->parent); tfm = pask->private; err = -ENOKEY ; -lock_sock (psk); +lock_sock_nested (psk,SINGLE_DEPTH_NESTING );if (!tfm->has_key) goto unlock;
@@ -263,6 +264,8 @@ static int hash_check_key(struct socket *sock) unlock:release_sock (psk); +unlock_child: +release_sock (sk);return err; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] crypto: algif_hash - Remove custom release parent function
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f1d84af1835846a5a2b827382c5848faf2bb0e75 ]
This patch removes the custom release parent function as the generic af_alg_release_parent now works for nokey sockets too.
--- crypto/algif_hash.c | 43 +++---------------------------------------- 1 file changed, 3 insertions(+), 40 deletions(-)
crypto/algif_hash.c +3 -40
@@ -376,7 +376,7 @@ static int hash_setkey(void *private, const u8 *key, unsigned int keylen)return err; } -static void hash_sock_destruct_common (struct sock *sk) +static void hash_sock_destruct (struct sock *sk) {struct alg_sock *ask =alg_sk (sk);struct hash_ctx *ctx = ask->private;
@@ -384,33 +384,10 @@ static void hash_sock_destruct_common(struct sock *sk)sock_kzfree_s (sk, ctx->result,crypto_ahash_digestsize (crypto_ahash_reqtfm (&ctx->req)));sock_kfree_s (sk, ctx, ctx->len); -} - -static void hash_sock_destruct (struct sock *sk) -{ -hash_sock_destruct_common (sk); -af_alg_release_parent (sk); -} - -static void hash_release_parent_nokey (struct sock *sk) -{ -struct alg_sock *ask =alg_sk (sk); - -if (!ask->refcnt) { -sock_put (ask->parent); -return ; - } -af_alg_release_parent (sk); } -static void hash_sock_destruct_nokey (struct sock *sk) -{ -hash_sock_destruct_common (sk); -hash_release_parent_nokey (sk); -} - -static int hash_accept_parent_common (void *private,struct sock *sk) +static int hash_accept_parent_nokey (void *private,struct sock *sk) {struct hash_ctx *ctx;struct alg_sock *ask =alg_sk (sk);
@@ -453,21 +430,7 @@ static int hash_accept_parent(void *private, struct sock *sk)if (!tfm->has_key &&crypto_ahash_has_setkey (tfm->hash))return -ENOKEY ; -return hash_accept_parent_common (private, sk); -} - -static int hash_accept_parent_nokey (void *private,struct sock *sk) -{ -int err; - - err =hash_accept_parent_common (private, sk); -if (err) - goto out; - - sk->sk_destruct = hash_sock_destruct_nokey; - -out: -return err; +return hash_accept_parent_nokey (private, sk); }static const struct af_alg_type algif_type_hash = {
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] dmaengine: at_xdmac: fix resume for cyclic transfers
In reply to Sasha LevinFrom: Songjun Wu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 611dcadb01c89d1d3521450c05a4ded332e5a32d ]
When having cyclic transfers, the channel was paused when performing suspend but was not correctly resumed.
eXtended DMA Controller driver")
--- drivers/dma/at_xdmac.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/dma/at_xdmac.c +3 -0
@@ -1230,6 +1230,7 @@ static int at_xdmac_device_terminate_all(struct dma_chan *chan)list_for_each_entry_safe (desc, _desc, &atchan->xfers_list, xfer_node)at_xdmac_remove_xfer (atchan, desc); +clear_bit (AT_XDMAC_CHAN_IS_PAUSED , &atchan->status);clear_bit (AT_XDMAC_CHAN_IS_CYCLIC , &atchan->status);spin_unlock_irqrestore (&atchan->lock, flags);
@@ -1362,6 +1363,8 @@ static int atmel_xdmac_resume(struct device *dev) atchan =to_at_xdmac_chan (chan);at_xdmac_chan_write (atchan,AT_XDMAC_CC , atchan->save_cc);if (at_xdmac_chan_is_cyclic (atchan)) { +if (at_xdmac_chan_is_paused (atchan)) +at_xdmac_device_resume (chan);at_xdmac_chan_write (atchan,AT_XDMAC_CNDA , atchan->save_cnda);at_xdmac_chan_write (atchan,AT_XDMAC_CNDC , atchan->save_cndc);at_xdmac_chan_write (atchan,AT_XDMAC_CIE , atchan->save_cim);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] ARM: debug-ll: fix BCM63xx entry for multiplatform
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6c54809977de3c9e2ef9e9934a2c6625f7e161e7 ]
During my randconfig build testing, I found that a kernel with DEBUG_AT91_UART and ARCH_BCM_63XX fails to build:
arch/arm/include/debug/at91.S:18:0: error: "CONFIG_DEBUG_UART_VIRT" redefined [-Werror]
It turns out that the DEBUG_UART_BCM63XX option is enabled whenever the ARCH_BCM_63XX is, and that breaks multiplatform kernels because we then end up using the UART address from BCM63XX rather than the one we actually configured (if any).
This changes the BCM63XX options to only have one Kconfig option, and only enable that if the user explicitly turns it on.
--- arch/arm/Kconfig.debug | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
arch/arm/Kconfig.debug +6 -11
@@ -161,10 +161,9 @@ choice mobile SoCs in the Kona family of chips (e.g. bcm28155, bcm11351, etc...) - config DEBUG_BCM63XX + config DEBUG_BCM63XX_UART bool "Kernel low-level debugging on BCM63XX UART" depends on ARCH_BCM_63XX - select DEBUG_UART_BCM63XX config DEBUG_BERLIN_UART bool "Marvell Berlin SoC Debug UART"
@@ -1304,7 +1303,7 @@ config DEBUG_LL_INCLUDE default "debug/vf.S" if DEBUG_VF_UART default "debug/vt8500.S" if DEBUG_VT8500_UART0 default "debug/zynq.S" if DEBUG_ZYNQ_UART0 || DEBUG_ZYNQ_UART1 - default "debug/bcm63xx.S" if DEBUG_UART_BCM63XX + default "debug/bcm63xx.S" if DEBUG_BCM63XX_UART default "debug/digicolor.S" if DEBUG_DIGICOLOR_UA0 default "mach/debug-macro.S"
@@ -1320,10 +1319,6 @@ config DEBUG_UART_8250 ARCH_IOP33X || ARCH_IXP4XX || \ ARCH_LPC32XX || ARCH_MV78XX0 || ARCH_ORION5X || ARCH_RPC -# Compatibility options for BCM63xx -config DEBUG_UART_BCM63XX - def_bool ARCH_BCM_63XX - config DEBUG_UART_PHYS hex "Physical base address of debug UART" default 0x00100a00 if DEBUG_NETX_UART
@@ -1415,7 +1410,7 @@ config DEBUG_UART_PHYS default 0xfffb0000 if DEBUG_OMAP1UART1 || DEBUG_OMAP7XXUART1 default 0xfffb0800 if DEBUG_OMAP1UART2 || DEBUG_OMAP7XXUART2 default 0xfffb9800 if DEBUG_OMAP1UART3 || DEBUG_OMAP7XXUART3 - default 0xfffe8600 if DEBUG_UART_BCM63XX + default 0xfffe8600 if DEBUG_BCM63XX_UART default 0xfffff700 if ARCH_IOP33X depends on ARCH_EP93XX || \ DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
@@ -1427,7 +1422,7 @@ config DEBUG_UART_PHYS DEBUG_RCAR_GEN2_SCIF0 || DEBUG_RCAR_GEN2_SCIF2 || \ DEBUG_RMOBILE_SCIFA0 || DEBUG_RMOBILE_SCIFA1 || \ DEBUG_RMOBILE_SCIFA4 || DEBUG_S3C24XX_UART || \ - DEBUG_UART_BCM63XX || DEBUG_ASM9260_UART || \ + DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \ DEBUG_SIRFSOC_UART || DEBUG_DIGICOLOR_UA0 config DEBUG_UART_VIRT
@@ -1466,7 +1461,7 @@ config DEBUG_UART_VIRT default 0xfb009000 if DEBUG_REALVIEW_STD_PORT default 0xfb10c000 if DEBUG_REALVIEW_PB1176_PORT default 0xfc40ab00 if DEBUG_BRCMSTB_UART - default 0xfcfe8600 if DEBUG_UART_BCM63XX + default 0xfcfe8600 if DEBUG_BCM63XX_UART default 0xfd000000 if ARCH_SPEAR3XX || ARCH_SPEAR6XX default 0xfd000000 if ARCH_SPEAR13XX default 0xfd012000 if ARCH_MV78XX0
@@ -1516,7 +1511,7 @@ config DEBUG_UART_VIRT DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_MESON_UARTAO || \ DEBUG_NETX_UART || \ DEBUG_QCOM_UARTDM || DEBUG_S3C24XX_UART || \ - DEBUG_UART_BCM63XX || DEBUG_ASM9260_UART || \ + DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \ DEBUG_SIRFSOC_UART || DEBUG_DIGICOLOR_UA0 config DEBUG_UART_8250_SHIFT
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] xfs: log mount failures don't wait for buffers to be released
In reply to Sasha LevinFrom: Dave Chinner <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 85bec5460ad8e05e0a8d70fb0f6750eb719ad092 ]
Recently I've been seeing xfs/051 fail on 1k block size filesystems. Trying to trace the events during the test lead to the problem going away, indicating that it was a race condition that lead to this ASSERT failure:
XFS: Assertion failed: atomic_read(&pag->pag_ref) == 0, file: fs/xfs/xfs_mount.c, line: 156
.....
[<ffffffff814e1257>] xfs_free_perag+0x87/0xb0 [<ffffffff814e21b9>] xfs_mountfs+0x4d9/0x900 [<ffffffff814e5dff>] xfs_fs_fill_super+0x3bf/0x4d0 [<ffffffff811d8800>] mount_bdev+0x180/0x1b0 [<ffffffff814e3ff5>] xfs_fs_mount+0x15/0x20 [<ffffffff811d90a8>] mount_fs+0x38/0x170 [<ffffffff811f4347>] vfs_kern_mount+0x67/0x120 [<ffffffff811f7018>] do_mount+0x218/0xd60 [<ffffffff811f7e5b>] SyS_mount+0x8b/0xd0
When I finally caught it with tracing enabled, I saw that AG 2 had an elevated reference count and a buffer was responsible for it. I tracked down the specific buffer, and found that it was missing the final reference count release that would put it back on the LRU and hence be found by xfs_wait_buftarg() calls in the log mount failure handling.
The last four traces for the buffer before the assert were (trimmed for relevance)
kworker/0:1-5259 xfs_buf_iodone: hold 2 lock 0 flags ASYNC kworker/0:1-5259 xfs_buf_ioerror: hold 2 lock 0 error -5 mount-7163 xfs_buf_lock_done: hold 2 lock 0 flags ASYNC mount-7163 xfs_buf_unlock: hold 2 lock 1 flags ASYNC
This is an async write that is completing, so there's nobody waiting for it directly. Hence we call xfs_buf_relse() once all the processing is complete. That does:
static inline void xfs_buf_relse(xfs_buf_t *bp)
{
xfs_buf_unlock(bp);
xfs_buf_rele(bp);
}Now, it's clear that mount is waiting on the buffer lock, and that it has been released by xfs_buf_relse() and gained by mount. This is expected, because at this point the mount process is in xfs_buf_delwri_submit() waiting for all the IO it submitted to complete.
The mount process, however, is waiting on the lock for the buffer because it is in xfs_buf_delwri_submit(). This waits for IO completion, but it doesn't wait for the buffer reference owned by the IO to go away. The mount process collects all the completions, fails the log recovery, and the higher level code then calls xfs_wait_buftarg() to free all the remaining buffers in the filesystem.
The issue is that on unlocking the buffer, the scheduler has decided that the mount process has higher priority than the the kworker thread that is running the IO completion, and so immediately switched contexts to the mount process from the semaphore unlock code, hence preventing the kworker thread from finishing the IO completion and releasing the IO reference to the buffer.
Hence by the time that xfs_wait_buftarg() is run, the buffer still has an active reference and so isn't on the LRU list that the function walks to free the remaining buffers. Hence we miss that buffer and continue onwards to tear down the mount structures, at which time we get find a stray reference count on the perag structure. On a non-debug kernel, this will be ignored and the structure torn down and freed. Hence when the kworker thread is then rescheduled and the buffer released and freed, it will access a freed perag structure.
The problem here is that when the log mount fails, we still need to quiesce the log to ensure that the IO workqueues have returned to idle before we run xfs_wait_buftarg(). By synchronising the workqueues, we ensure that all IO completions are fully processed, not just to the point where buffers have been unlocked. This ensures we don't end up in the situation above.
--- fs/xfs/xfs_buf.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/xfs/xfs_buf.c +10 -0
@@ -1529,6 +1529,16 @@ xfs_wait_buftarg(LIST_HEAD (dispose);int loop =0 ; +/* +* We need to flush the buffer workqueue to ensure that all IO +* completion processing is 100% done. Just waiting on buffer locks is +* not sufficient for async IO as the reference count held over IO is +* not released until after the buffer lock is dropped. Hence we need to +* ensure here that all reference counts have been dropped before we +* start walking the LRU list. +*/ +drain_workqueue (btp->bt_mount->m_buf_workqueue); +/* loop until there is nothing left on the lru list. */ while (list_lru_count (&btp->bt_lru)) { list_lru_walk(&btp->bt_lru, xfs_buftarg_wait_rele,
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] IB/qib: fix mcast detach when qp not attached
In reply to Sasha LevinFrom: Mike Marciniszyn <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 09dc9cd6528f5b52bcbd3292a6312e762c85260f ]
The code produces the following trace:
[1750924.419007] general protection fault: 0000 [#3] SMP [1750924.420364] Modules linked in: nfnetlink autofs4 rpcsec_gss_krb5 nfsv4
dcdbas rfcomm bnep bluetooth nfsd auth_rpcgss nfs_acl dm_multipath nfs lockd scsi_dh sunrpc fscache radeon ttm drm_kms_helper drm serio_raw parport_pc ppdev i2c_algo_bit lpc_ich ipmi_si ib_mthca ib_qib dca lp parport ib_ipoib mac_hid ib_cm i3000_edac ib_sa ib_uverbs edac_core ib_umad ib_mad ib_core ib_addr tg3 ptp dm_mirror dm_region_hash dm_log psmouse pps_core
[1750924.420364] CPU: 1 PID: 8401 Comm: python Tainted: G D 3.13.0-39-generic #66-Ubuntu [1750924.420364] Hardware name: Dell Computer Corporation PowerEdge 860/0XM089, BIOS A04 07/24/2007 [1750924.420364] task: ffff8800366a9800 ti: ffff88007af1c000 task.ti: ffff88007af1c000 [1750924.420364] RIP: 0010:[<ffffffffa0131d51>] [<ffffffffa0131d51>] qib_mcast_qp_free+0x11/0x50 [ib_qib] [1750924.420364] RSP: 0018:ffff88007af1dd70 EFLAGS: 00010246 [1750924.420364] RAX: 0000000000000001 RBX: ffff88007b822688 RCX: 000000000000000f [1750924.420364] RDX: ffff88007b822688 RSI: ffff8800366c15a0 RDI: 6764697200000000 [1750924.420364] RBP: ffff88007af1dd78 R08: 0000000000000001 R09: 0000000000000000 [1750924.420364] R10: 0000000000000011 R11: 0000000000000246 R12: ffff88007baa1d98 [1750924.420364] R13: ffff88003ecab000 R14: ffff88007b822660 R15: 0000000000000000 [1750924.420364] FS: 00007ffff7fd8740(0000) GS:ffff88007fc80000(0000) knlGS:0000000000000000 [1750924.420364] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [1750924.420364] CR2: 00007ffff597c750 CR3: 000000006860b000 CR4: 00000000000007e0 [1750924.420364] Stack: [1750924.420364] ffff88007b822688 ffff88007af1ddf0 ffffffffa0132429 000000007af1de20 [1750924.420364] ffff88007baa1dc8 ffff88007baa0000 ffff88007af1de70 ffffffffa00cb313 [1750924.420364] 00007fffffffde88 0000000000000000 0000000000000008 ffff88003ecab000 [1750924.420364] Call Trace: [1750924.420364] [<ffffffffa0132429>] qib_multicast_detach+0x1e9/0x350 [ib_qib] [1750924.568035] [<ffffffffa00cb313>] ? ib_uverbs_modify_qp+0x323/0x3d0 [ib_uverbs] [1750924.568035] [<ffffffffa0092d61>] ib_detach_mcast+0x31/0x50 [ib_core] [1750924.568035] [<ffffffffa00cc213>] ib_uverbs_detach_mcast+0x93/0x170 [ib_uverbs] [1750924.568035] [<ffffffffa00c61f6>] ib_uverbs_write+0xc6/0x2c0 [ib_uverbs] [1750924.568035] [<ffffffff81312e68>] ? apparmor_file_permission+0x18/0x20 [1750924.568035] [<ffffffff812d4cd3>] ? security_file_permission+0x23/0xa0 [1750924.568035] [<ffffffff811bd214>] vfs_write+0xb4/0x1f0 [1750924.568035] [<ffffffff811bdc49>] SyS_write+0x49/0xa0 [1750924.568035] [<ffffffff8172f7ed>] system_call_fastpath+0x1a/0x1f [1750924.568035] Code: 66 2e 0f 1f 84 00 00 00 00 00 31 c0 5d c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 0f 1f 44 00 00 55 48 89 e5 53 48 89 fb 48 8b 7f 10 <f0> ff 8f 40 01 00 00 74 0e 48 89 df e8 8e f8 06 e1 5b 5d c3 0f [1750924.568035] RIP [<ffffffffa0131d51>] qib_mcast_qp_free+0x11/0x50 [ib_qib] [1750924.568035] RSP <ffff88007af1dd70> [1750924.650439] ---[ end trace 73d5d4b3f8ad4851 ]
The fix is to note the qib_mcast_qp that was found. If none is found, then
return EINVAL indicating the error.
--- drivers/infiniband/hw/qib/qib_verbs_mcast.c | 35 +++++++++++++---------------- 1 file changed, 15 insertions(+), 20 deletions(-)
drivers/infiniband/hw/qib/qib_verbs_mcast.c +15 -20
@@ -286,15 +286,13 @@ int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)struct qib_ibdev *dev =to_idev (ibqp->device);struct qib_ibport *ibp =to_iport (ibqp->device, qp->port_num);struct qib_mcast *mcast =NULL ; -struct qib_mcast_qp *p, *tmp; +struct qib_mcast_qp *p, *tmp, *delp =NULL ;struct rb_node *n;int last =0 ;int ret; -if (ibqp->qp_num <=1 || qp->state ==IB_QPS_RESET ) { - ret = -EINVAL ; - goto bail; - } +if (ibqp->qp_num <=1 || qp->state ==IB_QPS_RESET ) +return -EINVAL ;spin_lock_irq (&ibp->lock);
@@ -303,8 +301,7 @@ int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)while (1 ) {if (n ==NULL ) {spin_unlock_irq (&ibp->lock); - ret = -EINVAL ; - goto bail; +return -EINVAL ; } mcast = rb_entry(n, struct qib_mcast, rb_node);
@@ -328,6 +325,7 @@ int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)*/ list_del_rcu (&p->list); mcast->n_attached--; + delp = p;/* If this was the last attached QP, remove the GID too. */ if (list_empty (&mcast->qp_list)) {
@@ -338,15 +336,16 @@ int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) }spin_unlock_irq (&ibp->lock); +/* QP not attached */ +if (!delp) +return -EINVAL ; +/* +* Wait for any list walkers to finish before freeing the +* list element. +*/ +wait_event (mcast->wait,atomic_read (&mcast->refcount) <=1 ); +qib_mcast_qp_free (delp); -if (p) { -/* -* Wait for any list walkers to finish before freeing the -* list element. -*/ -wait_event (mcast->wait,atomic_read (&mcast->refcount) <=1 ); -qib_mcast_qp_free (p); - }if (last) {atomic_dec (&mcast->refcount);wait_event (mcast->wait, !atomic_read (&mcast->refcount));
@@ -355,11 +354,7 @@ int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) dev->n_mcast_grps_allocated--;spin_unlock_irq (&dev->n_mcast_grps_lock); } - - ret =0 ; - -bail: -return ret; +return 0 ; }int qib_mcast_tree_empty (struct qib_ibport *ibp)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] ideapad-laptop: Add Lenovo ideapad Y700-17ISK to no_hw_rfkill dmi list
In reply to Sasha LevinFrom: Josh Boyer <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit edde316acb5f07c04abf09a92f59db5d2efd14e2 ]
One of the newest ideapad models also lacks a physical hw rfkill switch, and trying to read the hw rfkill switch through the ideapad module causes it to always reported blocking breaking wifi.
Fix it by adding this model to the DMI list.
--- drivers/platform/x86/ideapad-laptop.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/platform/x86/ideapad-laptop.c +7 -0
@@ -845,6 +845,13 @@ static const struct dmi_system_id no_hw_rfkill_list[] = { }, }, { + .ident = "Lenovo ideapad Y700-17ISK", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), + DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad Y700-17ISK"), + }, + }, + { .ident ="Lenovo Yoga 2 11 / 13 / Pro" , .matches = { DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] dma-debug: switch check from _text to _stext
In reply to Sasha LevinFrom: Laura Abbott <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ea535e418c01837d07b6c94e817540f50bfdadb0 ]
In include/asm-generic/sections.h:
/*
* Usage guidelines:
* _text, _data: architecture specific, don't use them in
* arch-independent code
* [_stext, _etext]: contains .text.* sections, may also contain
* .rodata.*
* and/or .init.* sections
_text is not guaranteed across architectures. Architectures such as ARM may reuse parts which are not actually text and erroneously trigger a bug. Switch to using _stext which is guaranteed to contain text sections.
Came out of https://lkml.kernel.org/g/<[email protected]>
--- lib/dma-debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/dma-debug.c +1 -1
@@ -1181,7 +1181,7 @@ static inline bool overlap(void *addr, unsigned long len, void *start, void *endstatic void check_for_illegal_area (struct device *dev,void *addr,unsigned long len) { -if (overlap (addr, len, _text, _etext) || +if (overlap (addr, len, _stext, _etext) ||overlap (addr, len, __start_rodata, __end_rodata))err_printk (dev,NULL ,"DMA-API: device driver maps memory from kernel text or rodata [addr=%p] [len=%lu]\n" , addr, len); }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] crypto: crc32c - Fix crc32c soft dependency
In reply to Sasha LevinFrom: Jean Delvare <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fd7f6727102a1ccf6b4c1dfcc631f9b546526b26 ]
I don't think it makes sense for a module to have a soft dependency on itself. This seems quite cyclic by nature and I can't see what purpose it could serve.
OTOH libcrc32c calls crypto_alloc_shash("crc32c", 0, 0) so it pretty much assumes that some incarnation of the "crc32c" hash algorithm has been loaded. Therefore it makes sense to have the soft dependency there (as crc-t10dif does.)
--- crypto/crc32c_generic.c | 1 - lib/libcrc32c.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)
crypto/crc32c_generic.c +0 -1
@@ -172,4 +172,3 @@ MODULE_DESCRIPTION("CRC32c (Castagnoli) calculations wrapper for lib/crc32c");MODULE_LICENSE ("GPL" );MODULE_ALIAS_CRYPTO ("crc32c" );MODULE_ALIAS_CRYPTO ("crc32c-generic" ); -MODULE_SOFTDEP ("pre: crc32c" );
lib/libcrc32c.c +1 -0
@@ -74,3 +74,4 @@ module_exit(libcrc32c_mod_fini);MODULE_AUTHOR ("Clay Haapala <[email protected]>" );MODULE_DESCRIPTION ("CRC32c (Castagnoli) calculations" );MODULE_LICENSE ("GPL" ); +MODULE_SOFTDEP ("pre: crc32c" );
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] btrfs: put delayed item hook into inode
In reply to Sasha LevinFrom: David Sterba <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8089fe62c6603860f6796ca80519b92391292f21 ]
Inodes for delayed iput allocate a trivial helper structure, let's place the list hook directly into the inode and save a kmalloc (killing a __GFP_NOFAIL as a bonus) at the cost of increasing size of btrfs_inode.
The inode can be put into the delayed_iputs list more than once and we have to keep the count. This means we can't use the list_splice to process a bunch of inodes because we'd lost track of the count if the inode is put into the delayed iputs again while it's processed.
--- fs/btrfs/btrfs_inode.h | 4 ++++ fs/btrfs/inode.c | 56 ++++++++++++++++++++++---------------------------- 2 files changed, 29 insertions(+), 31 deletions(-)
fs/btrfs/btrfs_inode.h +4 -0
@@ -192,6 +192,10 @@ struct btrfs_inode {/* File creation time. */ struct timespec i_otime; +/* Hook into fs_info->delayed_iputs */ +struct list_head delayed_iput; +long delayed_iput_count; +struct inode vfs_inode; };
fs/btrfs/inode.c +25 -31
92 lines not on this page · raw message
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] crypto: algif_skcipher - sendmsg SG marking is off by one
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 202736d99b7f29279db9da61587f11a08a04a9c6 ]
We mark the end of the SG list in sendmsg and sendpage and unmark it on the next send call. Unfortunately the unmarking in sendmsg is off-by-one, leading to an SG list that is too short.
--- crypto/algif_skcipher.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
crypto/algif_skcipher.c +2 -1
@@ -387,7 +387,8 @@ static int skcipher_sendmsg(struct socket *sock, struct msghdr *msg, sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list); sg = sgl->sg; -sg_unmark_end (sg + sgl->cur); +if (sgl->cur) +sg_unmark_end (sg + sgl->cur -1 ); do { i = sgl->cur; plen = min_t(int, len, PAGE_SIZE);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] IB/qib: Support creating qps with GFP_NOIO flag
In reply to Sasha LevinFrom: Vinit Agnihotri <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fbbeb8632bf0b46ab44cfcedc4654cd7831b7161 ]
The current code is problematic when the QP creation and ipoib is used to support NFS and NFS desires to do IO for paging purposes. In that case, the GFP_KERNEL allocation in qib_qp.c causes a deadlock in tight memory situations.
This fix adds support to create queue pair with GFP_NOIO flag for connected mode only to cleanly fail the create queue pair in those situations.
--- drivers/infiniband/hw/qib/qib_qp.c | 46 ++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 14 deletions(-)
drivers/infiniband/hw/qib/qib_qp.c +32 -14
@@ -100,9 +100,10 @@ static u32 credit_table[31] = { 32768 /* 1E */ }; -static void get_map_page (struct qib_qpn_table *qpt,struct qpn_map *map) +static void get_map_page (struct qib_qpn_table *qpt,struct qpn_map *map, +gfp_t gfp) { -unsigned long page =get_zeroed_page (GFP_KERNEL ); +unsigned long page =get_zeroed_page (gfp);/* * Free the page if someone raced with us installing it.
@@ -121,7 +122,7 @@ static void get_map_page(struct qib_qpn_table *qpt, struct qpn_map *map)* zero/one for QP type IB_QPT_SMI/IB_QPT_GSI. */ static int alloc_qpn (struct qib_devdata *dd,struct qib_qpn_table *qpt, -enum ib_qp_type type,u8 port) +enum ib_qp_type type,u8 port,gfp_t gfp) {u32 i, offset, max_scan, qpn;struct qpn_map *map;
@@ -151,7 +152,7 @@ static int alloc_qpn(struct qib_devdata *dd, struct qib_qpn_table *qpt, max_scan = qpt->nmaps - !offset;for (i =0 ;;) {if (unlikely (!map->page)) { -get_map_page (qpt, map); +get_map_page (qpt, map, gfp);if (unlikely (!map->page))break ; }
@@ -983,13 +984,21 @@ struct ib_qp *qib_create_qp(struct ib_pd *ibpd,size_t sz;size_t sg_list_sz;struct ib_qp *ret; +gfp_t gfp; +if (init_attr->cap.max_send_sge > ib_qib_max_sges || init_attr->cap.max_send_wr > ib_qib_max_qp_wrs || - init_attr->create_flags) { - ret =ERR_PTR (-EINVAL ); - goto bail; - } + init_attr->create_flags & ~(IB_QP_CREATE_USE_GFP_NOIO )) +return ERR_PTR (-EINVAL ); + +/* GFP_NOIO is applicable in RC QPs only */ +if (init_attr->create_flags &IB_QP_CREATE_USE_GFP_NOIO && + init_attr->qp_type !=IB_QPT_RC ) +return ERR_PTR (-EINVAL ); + + gfp = init_attr->create_flags &IB_QP_CREATE_USE_GFP_NOIO ? +GFP_NOIO :GFP_KERNEL ;/* Check receive queue parameters if no SRQ is specified. */ if (!init_attr->srq) {
@@ -1021,7 +1030,8 @@ struct ib_qp *qib_create_qp(struct ib_pd *ibpd, sz =sizeof (struct qib_sge ) * init_attr->cap.max_send_sge +sizeof (struct qib_swqe ); - swq =vmalloc ((init_attr->cap.max_send_wr +1 ) * sz); + swq =__vmalloc ((init_attr->cap.max_send_wr +1 ) * sz, + gfp,PAGE_KERNEL );if (swq ==NULL ) { ret =ERR_PTR (-ENOMEM ); goto bail;
@@ -1037,13 +1047,13 @@ struct ib_qp *qib_create_qp(struct ib_pd *ibpd, }else if (init_attr->cap.max_recv_sge >1 ) sg_list_sz =sizeof (*qp->r_sg_list) * (init_attr->cap.max_recv_sge -1 ); - qp =kzalloc (sz + sg_list_sz,GFP_KERNEL ); + qp =kzalloc (sz + sg_list_sz, gfp);if (!qp) { ret =ERR_PTR (-ENOMEM ); goto bail_swq; }RCU_INIT_POINTER (qp->next,NULL ); - qp->s_hdr =kzalloc (sizeof (*qp->s_hdr),GFP_KERNEL ); + qp->s_hdr =kzalloc (sizeof (*qp->s_hdr), gfp);if (!qp->s_hdr) { ret =ERR_PTR (-ENOMEM ); goto bail_qp;
@@ -1058,8 +1068,16 @@ struct ib_qp *qib_create_qp(struct ib_pd *ibpd, qp->r_rq.max_sge = init_attr->cap.max_recv_sge; sz = (sizeof (struct ib_sge ) * qp->r_rq.max_sge) +sizeof (struct qib_rwqe ); - qp->r_rq.wq =vmalloc_user (sizeof (struct qib_rwq ) + - qp->r_rq.size * sz); +if (gfp !=GFP_NOIO ) + qp->r_rq.wq =vmalloc_user ( +sizeof (struct qib_rwq ) + + qp->r_rq.size * sz); +else + qp->r_rq.wq =__vmalloc ( +sizeof (struct qib_rwq ) + + qp->r_rq.size * sz, + gfp,PAGE_KERNEL ); +if (!qp->r_rq.wq) { ret =ERR_PTR (-ENOMEM ); goto bail_qp;
@@ -1090,7 +1108,7 @@ struct ib_qp *qib_create_qp(struct ib_pd *ibpd, dev =to_idev (ibpd->device); dd =dd_from_dev (dev); err =alloc_qpn (dd, &dev->qpn_table, init_attr->qp_type, - init_attr->port_num); + init_attr->port_num, gfp);if (err <0 ) { ret =ERR_PTR (err);vfree (qp->r_rq.wq);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] string_helpers: fix precision loss for some inputs
In reply to Sasha LevinFrom: James Bottomley <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 564b026fbd0d28e9f70fb3831293d2922bb7855b ]
It was noticed that we lose precision in the final calculation for some inputs. The most egregious example is size=3000 blk_size=1900 in units of 10 should yield 5.70 MB but in fact yields 3.00 MB (oops).
This is because the current algorithm doesn't correctly account for all the remainders in the logarithms. Fix this by doing a correct calculation in the remainders based on napier's algorithm.
Additionally, now we have the correct result, we have to account for arithmetic rounding because we're printing 3 digits of precision. This means that if the fourth digit is five or greater, we have to round up, so add a section to ensure correct rounding. Finally account for all possible inputs correctly, including zero for block size.
--- lib/string_helpers.c | 63 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 20 deletions(-)
lib/string_helpers.c +43 -20
@@ -43,50 +43,73 @@ void string_get_size(u64 size, u64 blk_size, const enum string_size_units units, [STRING_UNITS_10] = 1000, [STRING_UNITS_2] = 1024, }; -int i, j; -u32 remainder =0 , sf_cap, exp; +static const unsigned int rounding[] = {500 ,50 ,5 }; +int i =0 , j; +u32 remainder =0 , sf_cap;char tmp[8 ];const char *unit; tmp[0 ] ='\0' ; - i =0 ; -if (!size) + +if (blk_size ==0 ) + size =0 ; +if (size ==0 ) goto out; -while (blk_size >= divisor[units]) { - remainder =do_div (blk_size, divisor[units]); +/* This is Napier's algorithm. Reduce the original block size to +* +* coefficient * divisor[units]^i +* +* we do the reduction so both coefficients are just under 32 bits so +* that multiplying them together won't overflow 64 bits and we keep +* as much precision as possible in the numbers. +* +* Note: it's safe to throw away the remainders here because all the +* precision is in the coefficients. +*/ +while (blk_size >>32 ) { +do_div (blk_size, divisor[units]); i++; } - exp = divisor[units] / (u32 )blk_size; -/* -* size must be strictly greater than exp here to ensure that remainder -* is greater than divisor[units] coming out of the if below. -*/ -if (size > exp) { - remainder =do_div (size, divisor[units]); - remainder *= blk_size; +while (size >>32 ) { +do_div (size, divisor[units]); i++; - }else { - remainder *= size; } +/* now perform the actual multiplication keeping i as the sum of the +* two logarithms */ size *= blk_size; - size += remainder / divisor[units]; - remainder %= divisor[units]; +/* and logarithmically reduce it until it's just under the divisor */ while (size >= divisor[units]) { remainder =do_div (size, divisor[units]); i++; } +/* work out in j how many digits of precision we need from the +* remainder */ sf_cap = size;for (j =0 ; sf_cap*10 <1000 ; j++) sf_cap *=10 ; -if (j) { +if (units ==STRING_UNITS_2 ) { +/* express the remainder as a decimal. It's currently the +* numerator of a fraction whose denominator is +* divisor[units], which is 1 << 10 for STRING_UNITS_2 */ remainder *=1000 ; - remainder /= divisor[units]; + remainder >>=10 ; + } + +/* add a 5 to the digit below what will be printed to ensure +* an arithmetical round up and carry it through to size */ + remainder += rounding[j]; +if (remainder >=1000 ) { + remainder -=1000 ; + size +=1 ; + } + +if (j) {snprintf (tmp,sizeof (tmp),".%03u" , remainder); tmp[j+1 ] ='\0' ; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] Btrfs: fix deadlock running delayed iputs at transaction commit time
In reply to Sasha LevinFrom: Filipe Manana <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c2d6cb1636d235257086f939a8194ef0bf93af6e ]
While running a stress test I ran into a deadlock when running the delayed iputs at transaction time, which produced the following report and trace:
[ 886.399989] =============================================
[ 886.400871] [ INFO: possible recursive locking detected ]
[ 886.401663] 4.4.0-rc6-btrfs-next-18+ #1 Not tainted
[ 886.402384] ---------------------------------------------
[ 886.403182] fio/8277 is trying to acquire lock:
[ 886.403568] (&fs_info->delayed_iput_sem){++++..}, at: [<ffffffffa0538823>] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[ 886.403568]
[ 886.403568] but task is already holding lock:
[ 886.403568] (&fs_info->delayed_iput_sem){++++..}, at: [<ffffffffa0538823>] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[ 886.403568]
[ 886.403568] other info that might help us debug this:
[ 886.403568] Possible unsafe locking scenario:
[ 886.403568]
[ 886.403568] CPU0
[ 886.403568] ----
[ 886.403568] lock(&fs_info->delayed_iput_sem);
[ 886.403568] lock(&fs_info->delayed_iput_sem);
[ 886.403568]
[ 886.403568] *** DEADLOCK ***
[ 886.403568]
[ 886.403568] May be due to missing lock nesting notation
[ 886.403568]
[ 886.403568] 3 locks held by fio/8277:
[ 886.403568] #0: (sb_writers#11){.+.+.+}, at: [<ffffffff81174c4c>] __sb_start_write+0x5f/0xb0
[ 886.403568] #1: (&sb->s_type->i_mutex_key#15){+.+.+.}, at: [<ffffffffa054620d>] btrfs_file_write_iter+0x73/0x408 [btrfs]
[ 886.403568] #2: (&fs_info->delayed_iput_sem){++++..}, at: [<ffffffffa0538823>] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[ 886.403568]
[ 886.403568] stack backtrace:
[ 886.403568] CPU: 6 PID: 8277 Comm: fio Not tainted 4.4.0-rc6-btrfs-next-18+ #1
[ 886.403568] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS by qemu-project.org 04/01/2014
[ 886.403568] 0000000000000000 ffff88009f80f770 ffffffff8125d4fd ffffffff82af1fc0
[ 886.403568] ffff88009f80f830 ffffffff8108e5f9 0000000200000000 ffff88009fd92290
[ 886.403568] 0000000000000000 ffffffff82af1fc0 ffffffff829cfb01 00042b216d008804
[ 886.403568] Call Trace:
[ 886.403568] [<ffffffff8125d4fd>] dump_stack+0x4e/0x79
[ 886.403568] [<ffffffff8108e5f9>] __lock_acquire+0xd42/0xf0b
[ 886.403568] [<ffffffff810c22db>] ? __module_address+0xdf/0x108
[ 886.403568] [<ffffffff8108eb77>] lock_acquire+0x10d/0x194
[ 886.403568] [<ffffffff8108eb77>] ? lock_acquire+0x10d/0x194
[ 886.403568] [<ffffffffa0538823>] ? btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[ 886.489542] [<ffffffff8148556b>] down_read+0x3e/0x4d
[ 886.489542] [<ffffffffa0538823>] ? btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[ 886.489542] [<ffffffffa0538823>] btrfs_run_delayed_iputs+0x36/0xbf [btrfs]
[ 886.489542] [<ffffffffa0533953>] btrfs_commit_transaction+0x8f5/0x96e [btrfs]
[ 886.489542] [<ffffffffa0521d7a>] flush_space+0x435/0x44a [btrfs]
[ 886.489542] [<ffffffffa052218b>] ? reserve_metadata_bytes+0x26a/0x384 [btrfs]
[ 886.489542] [<ffffffffa05221ae>] reserve_metadata_bytes+0x28d/0x384 [btrfs]
[ 886.489542] [<ffffffffa052256c>] ? btrfs_block_rsv_refill+0x58/0x96 [btrfs]
[ 886.489542] [<ffffffffa0522584>] btrfs_block_rsv_refill+0x70/0x96 [btrfs]
[ 886.489542] [<ffffffffa053d747>] btrfs_evict_inode+0x394/0x55a [btrfs]
[ 886.489542] [<ffffffff81188e31>] evict+0xa7/0x15c
[ 886.489542] [<ffffffff81189878>] iput+0x1d3/0x266
[ 886.489542] [<ffffffffa053887c>] btrfs_run_delayed_iputs+0x8f/0xbf [btrfs]
[ 886.489542] [<ffffffffa0533953>] btrfs_commit_transaction+0x8f5/0x96e [btrfs]
[ 886.489542] [<ffffffff81085096>] ? signal_pending_state+0x31/0x31
[ 886.489542] [<ffffffffa0521191>] btrfs_alloc_data_chunk_ondemand+0x1d7/0x288 [btrfs]
[ 886.489542] [<ffffffffa0521282>] btrfs_check_data_free_space+0x40/0x59 [btrfs]
[ 886.489542] [<ffffffffa05228f5>] btrfs_delalloc_reserve_space+0x1e/0x4e [btrfs]
[ 886.489542] [<ffffffffa053620a>] btrfs_direct_IO+0x10c/0x27e [btrfs]
[ 886.489542] [<ffffffff8111d9a1>] generic_file_direct_write+0xb3/0x128
[ 886.489542] [<ffffffffa05463c3>] btrfs_file_write_iter+0x229/0x408 [btrfs]
[ 886.489542] [<ffffffff8108ae38>] ? __lock_is_held+0x38/0x50
[ 886.489542] [<ffffffff8117279e>] __vfs_write+0x7c/0xa5
[ 886.489542] [<ffffffff81172cda>] vfs_write+0xa0/0xe4
[ 886.489542] [<ffffffff811734cc>] SyS_write+0x50/0x7e
[ 886.489542] [<ffffffff814872d7>] entry_SYSCALL_64_fastpath+0x12/0x6f
[ 1081.852335] INFO: task fio:8244 blocked for more than 120 seconds.
[ 1081.854348] Not tainted 4.4.0-rc6-btrfs-next-18+ #1
[ 1081.857560] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1081.863227] fio D ffff880213f9bb28 0 8244 8240 0x00000000
[ 1081.868719] ffff880213f9bb28 00ffffff810fc6b0 ffffffff0000000a ffff88023ed55240
[ 1081.872499] ffff880206b5d400 ffff880213f9c000 ffff88020a4d5318 ffff880206b5d400
[ 1081.876834] ffffffff00000001 ffff880206b5d400 ffff880213f9bb40 ffffffff81482ba4
[ 1081.880782] Call Trace:
[ 1081.881793] [<ffffffff81482ba4>] schedule+0x7f/0x97
[ 1081.883340] [<ffffffff81485eb5>] rwsem_down_write_failed+0x2d5/0x325
[ 1081.895525] [<ffffffff8108d48d>] ? trace_hardirqs_on_caller+0x16/0x1ab
[ 1081.897419] [<ffffffff81269723>] call_rwsem_down_write_failed+0x13/0x20
[ 1081.899251] [<ffffffff81269723>] ? call_rwsem_down_write_failed+0x13/0x20
[ 1081.901063] [<ffffffff81089fae>] ? __down_write_nested.isra.0+0x1f/0x21
[ 1081.902365] [<ffffffff814855bd>] down_write+0x43/0x57
[ 1081.903846] [<ffffffffa05211b0>] ? btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1081.906078] [<ffffffffa05211b0>] btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1081.908846] [<ffffffff8108d461>] ? mark_held_locks+0x56/0x6c
[ 1081.910409] [<ffffffffa0521282>] btrfs_check_data_free_space+0x40/0x59 [btrfs]
[ 1081.912482] [<ffffffffa05228f5>] btrfs_delalloc_reserve_space+0x1e/0x4e [btrfs]
[ 1081.914597] [<ffffffffa053620a>] btrfs_direct_IO+0x10c/0x27e [btrfs]
[ 1081.919037] [<ffffffff8111d9a1>] generic_file_direct_write+0xb3/0x128
[ 1081.920754] [<ffffffffa05463c3>] btrfs_file_write_iter+0x229/0x408 [btrfs]
[ 1081.922496] [<ffffffff8108ae38>] ? __lock_is_held+0x38/0x50
[ 1081.923922] [<ffffffff8117279e>] __vfs_write+0x7c/0xa5
[ 1081.925275] [<ffffffff81172cda>] vfs_write+0xa0/0xe4
[ 1081.926584] [<ffffffff811734cc>] SyS_write+0x50/0x7e
[ 1081.927968] [<ffffffff814872d7>] entry_SYSCALL_64_fastpath+0x12/0x6f
[ 1081.985293] INFO: lockdep is turned off.
[ 1081.986132] INFO: task fio:8249 blocked for more than 120 seconds.
[ 1081.987434] Not tainted 4.4.0-rc6-btrfs-next-18+ #1
[ 1081.988534] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1081.990147] fio D ffff880218febbb8 0 8249 8240 0x00000000
[ 1081.991626] ffff880218febbb8 00ffffff81486b8e ffff88020000000b ffff88023ed75240
[ 1081.993258] ffff8802120a9a00 ffff880218fec000 ffff88020a4d5318 ffff8802120a9a00
[ 1081.994850] ffffffff00000001 ffff8802120a9a00 ffff880218febbd0 ffffffff81482ba4
[ 1081.996485] Call Trace:
[ 1081.997037] [<ffffffff81482ba4>] schedule+0x7f/0x97
[ 1081.998017] [<ffffffff81485eb5>] rwsem_down_write_failed+0x2d5/0x325
[ 1081.999241] [<ffffffff810852a5>] ? finish_wait+0x6d/0x76
[ 1082.000306] [<ffffffff81269723>] call_rwsem_down_write_failed+0x13/0x20
[ 1082.001533] [<ffffffff81269723>] ? call_rwsem_down_write_failed+0x13/0x20
[ 1082.002776] [<ffffffff81089fae>] ? __down_write_nested.isra.0+0x1f/0x21
[ 1082.003995] [<ffffffff814855bd>] down_write+0x43/0x57
[ 1082.005000] [<ffffffffa05211b0>] ? btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1082.007403] [<ffffffffa05211b0>] btrfs_alloc_data_chunk_ondemand+0x1f6/0x288 [btrfs]
[ 1082.008988] [<ffffffffa0545064>] btrfs_fallocate+0x7c1/0xc2f [btrfs]
[ 1082.010193] [<ffffffff8108a1ba>] ? percpu_down_read+0x4e/0x77
[ 1082.011280] [<ffffffff81174c4c>] ? __sb_start_write+0x5f/0xb0
[ 1082.012265] [<ffffffff81174c4c>] ? __sb_start_write+0x5f/0xb0
[ 1082.013021] [<ffffffff811712e4>] vfs_fallocate+0x170/0x1ff
[ 1082.013738] [<ffffffff81181ebb>] ioctl_preallocate+0x89/0x9b
[ 1082.014778] [<ffffffff811822d7>] do_vfs_ioctl+0x40a/0x4ea
[ 1082.015778] [<ffffffff81176ea7>] ? SYSC_newfstat+0x25/0x2e
[ 1082.016806] [<ffffffff8118b4de>] ? __fget_light+0x4d/0x71
[ 1082.017789] [<ffffffff8118240e>] SyS_ioctl+0x57/0x79
[ 1082.018706] [<ffffffff814872d7>] entry_SYSCALL_64_fastpath+0x12/0x6fThis happens because we can recursively acquire the semaphore fs_info->delayed_iput_sem when attempting to allocate space to satisfy a file write request as shown in the first trace above - when committing a transaction we acquire (down_read) the semaphore before running the delayed iputs, and when running a delayed iput() we can end up calling an inode's eviction handler, which in turn commits another transaction and attempts to acquire (down_read) again the semaphore to run more delayed iput operations.
This results in a deadlock because if a task acquires multiple times a semaphore it should invoke down_read_nested() with a different lockdep class for each level of recursion.
Fix this by simplifying the implementation and use a mutex instead that is acquired by the cleaner kthread before it runs the delayed iputs instead of always acquiring a semaphore before delayed references are run from anywhere.
--- fs/btrfs/ctree.h | 2 +- fs/btrfs/disk-io.c | 5 ++++- fs/btrfs/extent-tree.c | 9 +++++---- fs/btrfs/inode.c | 2 -- 4 files changed, 10 insertions(+), 8 deletions(-)
fs/btrfs/ctree.h +1 -1
@@ -1544,7 +1544,7 @@ struct btrfs_fs_info {spinlock_t delayed_iput_lock;struct list_head delayed_iputs; -struct rw_semaphore delayed_iput_sem; +struct mutex cleaner_delayed_iput_mutex;/* this protects tree_mod_seq_list */ spinlock_t tree_mod_seq_lock;
fs/btrfs/disk-io.c +4 -1
@@ -1772,8 +1772,11 @@ static int cleaner_kthread(void *arg) goto sleep; } +mutex_lock (&root->fs_info->cleaner_delayed_iput_mutex);btrfs_run_delayed_iputs (root);btrfs_delete_unused_bgs (root->fs_info); +mutex_unlock (&root->fs_info->cleaner_delayed_iput_mutex); + again =btrfs_clean_one_deleted_snapshot (root);mutex_unlock (&root->fs_info->cleaner_mutex);
@@ -2491,8 +2494,8 @@ int open_ctree(struct super_block *sb,mutex_init (&fs_info->unused_bg_unpin_mutex);mutex_init (&fs_info->reloc_mutex);mutex_init (&fs_info->delalloc_root_mutex); +mutex_init (&fs_info->cleaner_delayed_iput_mutex);seqlock_init (&fs_info->profiles_lock); -init_rwsem (&fs_info->delayed_iput_sem);init_completion (&fs_info->kobj_unregister);INIT_LIST_HEAD (&fs_info->dirty_cowonly_roots);
fs/btrfs/extent-tree.c +5 -4
@@ -3985,11 +3985,12 @@ commit_trans:if (ret)return ret;/* -* make sure that all running delayed iput are -* done +* The cleaner kthread might still be doing iput +* operations. Wait for it to finish so that +* more space is released. */ -down_write (&root->fs_info->delayed_iput_sem); -up_write (&root->fs_info->delayed_iput_sem); +mutex_lock (&root->fs_info->cleaner_delayed_iput_mutex); +mutex_unlock (&root->fs_info->cleaner_delayed_iput_mutex); goto again; }else {btrfs_end_transaction (trans, root);
fs/btrfs/inode.c +0 -2
@@ -3102,7 +3102,6 @@ void btrfs_run_delayed_iputs(struct btrfs_root *root) {struct btrfs_fs_info *fs_info = root->fs_info; -down_read (&fs_info->delayed_iput_sem);spin_lock (&fs_info->delayed_iput_lock);while (!list_empty (&fs_info->delayed_iputs)) {struct btrfs_inode *inode;
@@ -3121,7 +3120,6 @@ void btrfs_run_delayed_iputs(struct btrfs_root *root)spin_lock (&fs_info->delayed_iput_lock); }spin_unlock (&fs_info->delayed_iput_lock); -up_read (&root->fs_info->delayed_iput_sem); }/*
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] libceph: fix ceph_msg_revoke()
In reply to Sasha LevinFrom: Ilya Dryomov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 67645d7619738e51c668ca69f097cb90b5470422 ]
There are a number of problems with revoking a "was sending" message:
(1) We never make any attempt to revoke data - only kvecs contibute to con->out_skip. However, once the header (envelope) is written to the socket, our peer learns data_len and sets itself to expect at least data_len bytes to follow front or front+middle. If ceph_msg_revoke() is called while the messenger is sending message's data portion, anything we send after that call is counted by the OSD towards the now revoked message's data portion. The effects vary, the most common one is the eventual hang - higher layers get stuck waiting for the reply to the message that was sent out after ceph_msg_revoke() returned and treated by the OSD as a bunch of data bytes. This is what Matt ran into.
(2) Flat out zeroing con->out_kvec_bytes worth of bytes to handle kvecs is wrong. If ceph_msg_revoke() is called before the tag is sent out or while the messenger is sending the header, we will get a connection reset, either due to a bad tag (0 is not a valid tag) or a bad header CRC, which kind of defeats the purpose of revoke. Currently the kernel client refuses to work with header CRCs disabled, but that will likely change in the future, making this even worse.
(3) con->out_skip is not reset on connection reset, leading to one or more spurious connection resets if we happen to get a real one between con->out_skip is set in ceph_msg_revoke() and before it's cleared in write_partial_skip().
Fixing (1) and (3) is trivial. The idea behind fixing (2) is to never zero the tag or the header, i.e. send out tag+header regardless of when ceph_msg_revoke() is called. That way the header is always correct, no unnecessary resets are induced and revoke stands ready for disabled CRCs. Since ceph_msg_revoke() rips out con->out_msg, introduce a new "message out temp" and copy the header into it before sending.
--- include/linux/ceph/messenger.h | 2 +- net/ceph/messenger.c | 76 ++++++++++++++++++++++++++++++++---------- 2 files changed, 59 insertions(+), 19 deletions(-)
include/linux/ceph/messenger.h +1 -1
@@ -224,6 +224,7 @@ struct ceph_connection {struct ceph_entity_addr actual_peer_addr;/* message out temps */ +struct ceph_msg_header out_hdr;struct ceph_msg *out_msg;/* sending message (== tail of out_sent) */ bool out_msg_done;
@@ -233,7 +234,6 @@ struct ceph_connection {int out_kvec_left;/* kvec's left in out_kvec */ int out_skip;/* skip this many bytes */ int out_kvec_bytes;/* total bytes left */ -bool out_kvec_is_msg;/* kvec refers to out_msg */ int out_more;/* there is more data after the kvecs */ __le64 out_temp_ack;/* for writing an ack */
net/ceph/messenger.c +58 -18
165 lines not on this page · raw message
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] zsmalloc: fix migrate_zspage-zs_free race condition
In reply to Sasha LevinFrom: Junil Lee <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c102f07ca0b04f2cb49cfc161c83f6239d17f491 ]
record_obj() in migrate_zspage() does not preserve handle's HANDLE_PIN_BIT, set by find_aloced_obj()->trypin_tag(), and implicitly (accidentally) un-pins the handle, while migrate_zspage() still performs an explicit unpin_tag() on the that handle. This additional explicit unpin_tag() introduces a race condition with zs_free(), which can pin that handle by this time, so the handle becomes un-pinned.
Schematically, it goes like this:
CPU0 CPU1
migrate_zspage
find_alloced_obj
trypin_tag
set HANDLE_PIN_BIT zs_free()
pin_tag()
obj_malloc() -- new object, no tag
record_obj() -- remove HANDLE_PIN_BIT set HANDLE_PIN_BIT
unpin_tag() -- remove zs_free's HANDLE_PIN_BIT
The race condition may result in a NULL pointer dereference:
Unable to handle kernel NULL pointer dereference at virtual address 00000000
CPU: 0 PID: 19001 Comm: CookieMonsterCl Tainted:
PC is at get_zspage_mapping+0x0/0x24
LR is at obj_free.isra.22+0x64/0x128
Call trace:
get_zspage_mapping+0x0/0x24
zs_free+0x88/0x114
zram_free_page+0x64/0xcc
zram_slot_free_notify+0x90/0x108
swap_entry_free+0x278/0x294
free_swap_and_cache+0x38/0x11c
unmap_single_vma+0x480/0x5c8
unmap_vmas+0x44/0x60
exit_mmap+0x50/0x110
mmput+0x58/0xe0
do_exit+0x320/0x8dc
do_group_exit+0x44/0xa8
get_signal+0x538/0x580
do_signal+0x98/0x4b8
do_notify_resume+0x14/0x5cThis patch keeps the lock bit in migration path and update value atomically.
--- mm/zsmalloc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
mm/zsmalloc.c +13 -1
@@ -306,7 +306,12 @@ static void free_handle(struct zs_pool *pool, unsigned long handle)static void record_obj (unsigned long handle,unsigned long obj) { - *(unsigned long *)handle = obj; +/* +* lsb of @obj represents handle lock while other bits +* represent object value the handle is pointing so +* updating shouldn't do store tearing. +*/ +WRITE_ONCE (*(unsigned long *)handle, obj); }/* zpool driver */
@@ -1641,6 +1646,13 @@ static int migrate_zspage(struct zs_pool *pool, struct size_class *class, free_obj =obj_malloc (d_page, class, handle);zs_object_copy (used_obj, free_obj, class); index++; +/* +* record_obj updates handle's value to free_obj and it will +* invalidate lock bit(ie, HANDLE_PIN_BIT) of handle, which +* breaks synchronization using pin_tag(e,g, zs_free) so +* let's keep the lock bit. +*/ + free_obj |=BIT (HANDLE_PIN_BIT );record_obj (handle, free_obj);unpin_tag (handle);obj_free (pool, class, used_obj);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] powerpc: Simplify module TOC handling
In reply to Sasha LevinFrom: Alan Modra <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9 ]
PowerPC64 uses the symbol .TOC. much as other targets use _GLOBAL_OFFSET_TABLE_. It identifies the value of the GOT pointer (or in powerpc parlance, the TOC pointer). Global offset tables are generally local to an executable or shared library, or in the kernel, module. Thus it does not make sense for a module to resolve a relocation against .TOC. to the kernel's .TOC. value. A module has its own .TOC., and indeed the powerpc64 module relocation processing ignores the kernel value of .TOC. and instead calculates a module-local value.
This patch removes code involved in exporting the kernel .TOC., tweaks modpost to ignore an undefined .TOC., and the module loader to twiddle the section symbol so that .TOC. isn't seen as undefined.
Note that if the kernel was compiled with -msingle-pic-base then ELFv2 would not have function global entry code setting up r2. In that case the module call stubs would need to be modified to set up r2 using the kernel .TOC. value, requiring some of this code to be reinstated.
mpe: Furthermore a change in binutils master (not yet released) causes the current way we handle the TOC to no longer work when building with MODVERSIONS=y and RELOCATABLE=n. The symptom is that modules can not be loaded due to there being no version found for TOC.
--- arch/powerpc/kernel/misc_64.S | 28 ---------------------------- arch/powerpc/kernel/module_64.c | 12 +++++++++--- scripts/mod/modpost.c | 3 ++- 3 files changed, 11 insertions(+), 32 deletions(-)
arch/powerpc/kernel/misc_64.S +0 -28
@@ -634,31 +634,3 @@ _GLOBAL(kexec_sequence) li r5,0 blr /* image->start(physid, image->start, 0); */ #endif /* CONFIG_KEXEC */ - -#ifdef CONFIG_MODULES -#if defined(_CALL_ELF) && _CALL_ELF == 2 - -#ifdef CONFIG_MODVERSIONS -.weak __crc_TOC. -.section "___kcrctab+TOC.","a" -.globl __kcrctab_TOC. -__kcrctab_TOC.: - .llong __crc_TOC. -#endif - -/* - * Export a fake .TOC. since both modpost and depmod will complain otherwise. - * Both modpost and depmod strip the leading . so we do the same here. - */ -.section "__ksymtab_strings","a" -__kstrtab_TOC.: - .asciz "TOC." - -.section "___ksymtab+TOC.","a" -/* This symbol name is important: it's used by modpost to find exported syms */ -.globl __ksymtab_TOC. -__ksymtab_TOC.: - .llong 0 /* .value */ - .llong __kstrtab_TOC. -#endif /* ELFv2 */ -#endif /* MODULES */
arch/powerpc/kernel/module_64.c +9 -3
@@ -326,7 +326,10 @@ static void dedotify_versions(struct modversion_info *vers, } } -/* Undefined symbols which refer to .funcname, hack to funcname (or .TOC.) */ +/* +* Undefined symbols which refer to .funcname, hack to funcname. Make .TOC. +* seem to be defined (value set later). +*/ static void dedotify (Elf64_Sym *syms,unsigned int numsyms,char *strtab) {unsigned int i;
@@ -334,8 +337,11 @@ static void dedotify(Elf64_Sym *syms, unsigned int numsyms, char *strtab)for (i =1 ; i < numsyms; i++) {if (syms[i].st_shndx ==SHN_UNDEF ) {char *name = strtab + syms[i].st_name; -if (name[0 ] =='.' ) +if (name[0 ] =='.' ) { +if (strcmp (name+1 ,"TOC." ) ==0 ) + syms[i].st_shndx =SHN_ABS ;memmove (name, name+1 ,strlen (name)); + } } } }
@@ -351,7 +357,7 @@ static Elf64_Sym *find_dot_toc(Elf64_Shdr *sechdrs, numsyms = sechdrs[symindex].sh_size /sizeof (Elf64_Sym);for (i =1 ; i < numsyms; i++) { -if (syms[i].st_shndx ==SHN_UNDEF +if (syms[i].st_shndx ==SHN_ABS &&strcmp (strtab + syms[i].st_name,"TOC." ) ==0 )return &syms[i]; }
scripts/mod/modpost.c +2 -1
@@ -593,7 +593,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)if (strncmp (symname,"_restgpr0_" ,sizeof ("_restgpr0_" ) -1 ) ==0 ||strncmp (symname,"_savegpr0_" ,sizeof ("_savegpr0_" ) -1 ) ==0 ||strncmp (symname,"_restvr_" ,sizeof ("_restvr_" ) -1 ) ==0 || -strncmp (symname,"_savevr_" ,sizeof ("_savevr_" ) -1 ) ==0 ) +strncmp (symname,"_savevr_" ,sizeof ("_savevr_" ) -1 ) ==0 || +strcmp (symname,".TOC." ) ==0 )return 1 ;/* Do not ignore this symbol */ return 0 ;
Signature · 1 line
2.5.0
Michael Ellerman
reviewerRe: [added to the 4.1 stable tree] powerpc: Simplify module TOC handling
Quoted 11 lines · Sasha Levin
From: Alan Modra <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9]PowerPC64 uses the symbol .TOC. much as other targets use _GLOBAL_OFFSET_TABLE_. It identifies the value of the GOT pointer (or in
Please drop this commit, it requires a corresponding change to depmod which we need to get accepted first.
cheers
Re: [added to the 4.1 stable tree] powerpc: Simplify module TOC handling
Quoted 9 lines · Michael Ellerman
Quoted 7 lines · Sasha Levin
From: Alan Modra <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
Quoted 8 lines
Quoted 4 lines
[ Upstream commit
c153693d7eb9eeb28478aa2deaaf0b4e7b5ff5e9]PowerPC64 uses the symbol .TOC. much as other targets use _GLOBAL_OFFSET_TABLE_. It identifies the value of the GOT pointer (or in
Please drop this commit, it requires a corresponding change to depmod which we need to get accepted first.
Dropped from both 4.1 and 3.18. Thanks!
Thanks,
Sasha
[added to the 4.1 stable tree] mm: fix mlock accouting
In reply to Sasha LevinFrom: "Kirill A. Shutemov" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7162a1e87b3e380133dadc7909081bb70d0a7041 ]
Tetsuo Handa reported underflow of NR_MLOCK on munlock.
Testcase:
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#define BASE ((void *)0x400000000000)
#define SIZE (1UL << 21)
int main(int argc, char *argv[])
{
void *addr;
system("grep Mlocked /proc/meminfo");
addr = mmap(BASE, SIZE, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE | MAP_LOCKED | MAP_FIXED,
-1, 0);
if (addr == MAP_FAILED)
printf("mmap() failed\n"), exit(1);
munmap(addr, SIZE);
system("grep Mlocked /proc/meminfo");
return 0;
}It happens on munlock_vma_page() due to unfortunate choice of nr_pages data type:
__mod_zone_page_state(zone, NR_MLOCK, -nr_pages);
For unsigned int nr_pages, implicitly casted to long in __mod_zone_page_state(), it becomes something around UINT_MAX.
munlock_vma_page() usually called for THP as small pages go though pagevec.
Let's make nr_pages signed int.
Similar fixes in 6cdb18ad98a4 ("mm/vmstat: fix overflow in mod_zone_page_state()") used long' type, but int' here is OK for a count of the number of sub-pages in a huge page.
--- mm/mlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mlock.c +1 -1
@@ -172,7 +172,7 @@ static void __munlock_isolation_failed(struct page *page)*/ unsigned int munlock_vma_page (struct page *page) { -unsigned int nr_pages; +int nr_pages;struct zone *zone =page_zone (page);/* For try_to_munlock() and to serialize with page migration */
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] pNFS/flexfiles: Fix an XDR encoding bug in layoutreturn
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 082fa37d1351a41afc491d44a1d095cb8d919aa2 ]
We must not skip encoding the statistics, or the server will see an XDR encoding error.
--- fs/nfs/flexfilelayout/flexfilelayout.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/nfs/flexfilelayout/flexfilelayout.c +2 -4
@@ -1484,11 +1484,9 @@ ff_layout_encode_layoutreturn(struct pnfs_layout_hdr *lo, start =xdr_reserve_space (xdr,4 );BUG_ON (!start); -if (ff_layout_encode_ioerr (flo, xdr, args)) - goto out; - +ff_layout_encode_ioerr (flo, xdr, args);ff_layout_encode_iostats (flo, xdr, args); -out: + *start =cpu_to_be32 ((xdr->p - start -1 ) *4 );dprintk ("%s: Return\n" , __func__); }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] ideapad-laptop: Add Lenovo Yoga 900 to no_hw_rfkill dmi list
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f71c882dd4cfe4aa88ea07b1402ddd43605d4aef ]
Like some of the other Yoga models the Lenovo Yoga 900 does not have a hw rfkill switch, and trying to read the hw rfkill switch through the ideapad module causes it to always reported blocking breaking wifi.
This commit adds the Lenovo Yoga 900 to the no_hw_rfkill dmi list, fixing the wifi breakage.
--- drivers/platform/x86/ideapad-laptop.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/platform/x86/ideapad-laptop.c +7 -0
@@ -872,6 +872,13 @@ static const struct dmi_system_id no_hw_rfkill_list[] = { DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo YOGA 3 Pro-1370"), }, }, + { + .ident = "Lenovo Yoga 900", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo YOGA 900"), + }, + }, {} };
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] prctl: take mmap sem for writing to protect against others
In reply to Sasha LevinFrom: Mateusz Guzik <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ddf1d398e517e660207e2c807f76a90df543a217 ]
An unprivileged user can trigger an oops on a kernel with CONFIG_CHECKPOINT_RESTORE.
proc_pid_cmdline_read takes mmap_sem for reading and obtains args + env start/end values. These get sanity checked as follows:
BUG_ON(arg_start > arg_end);
BUG_ON(env_start > env_end);These can be changed by prctl_set_mm. Turns out also takes the semaphore for reading, effectively rendering it useless. This results in:
kernel BUG at fs/proc/base.c:240!
invalid opcode: 0000 [#1] SMP
Modules linked in: virtio_net
CPU: 0 PID: 925 Comm: a.out Not tainted 4.4.0-rc8-next-20160105dupa+ #71
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
task: ffff880077a68000 ti: ffff8800784d0000 task.ti: ffff8800784d0000
RIP: proc_pid_cmdline_read+0x520/0x530
RSP: 0018:ffff8800784d3db8 EFLAGS: 00010206
RAX: ffff880077c5b6b0 RBX: ffff8800784d3f18 RCX: 0000000000000000
RDX: 0000000000000002 RSI: 00007f78e8857000 RDI: 0000000000000246
RBP: ffff8800784d3e40 R08: 0000000000000008 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000050
R13: 00007f78e8857800 R14: ffff88006fcef000 R15: ffff880077c5b600
FS: 00007f78e884a740(0000) GS:ffff88007b200000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 00007f78e8361770 CR3: 00000000790a5000 CR4: 00000000000006f0
Call Trace:
__vfs_read+0x37/0x100
vfs_read+0x82/0x130
SyS_read+0x58/0xd0
entry_SYSCALL_64_fastpath+0x12/0x76
Code: 4c 8b 7d a8 eb e9 48 8b 9d 78 ff ff ff 4c 8b 7d 90 48 8b 03 48 39 45 a8 0f 87 f0 fe ff ff e9 d1 fe ff ff 4c 8b 7d 90 eb c6 0f 0b <0f> 0b 0f 0b 66 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00
RIP proc_pid_cmdline_read+0x520/0x530
---[ end trace 97882617ae9c6818 ]---Turns out there are instances where the code just reads aformentioned values without locking whatsoever - namely environ_read and get_cmdline.
Interestingly these functions look quite resilient against bogus values, but I don't believe this should be relied upon.
The first patch gets rid of the oops bug by grabbing mmap_sem for writing.
The second patch is optional and puts locking around aformentioned consumers for safety. Consumers of other fields don't seem to benefit from similar treatment and are left untouched.
This patch (of 2):
The code was taking the semaphore for reading, which does not protect against readers nor concurrent modifications.
The problem could cause a sanity checks to fail in procfs's cmdline reader, resulting in an OOPS.
Note that some functions perform an unlocked read of various mm fields, but they seem to be fine despite possible modificaton.
--- kernel/sys.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
kernel/sys.c +10 -10
@@ -1854,11 +1854,13 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data user_auxv[AT_VECTOR_SIZE -1 ] =AT_NULL ; } -if (prctl_map.exe_fd != (u32)-1 ) +if (prctl_map.exe_fd != (u32)-1 ) { error =prctl_set_mm_exe_file (mm, prctl_map.exe_fd); -down_read (&mm->mmap_sem); -if (error) - goto out; +if (error) +return error; + } + +down_write (&mm->mmap_sem);/* * We don't validate if these members are pointing to
@@ -1895,10 +1897,8 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long dataif (prctl_map.auxv_size)memcpy (mm->saved_auxv, user_auxv,sizeof (user_auxv)); - error =0 ; -out: -up_read (&mm->mmap_sem); - return error; +up_write (&mm->mmap_sem); + return 0; }#endif /* CONFIG_CHECKPOINT_RESTORE */
@@ -1930,7 +1930,7 @@ static int prctl_set_mm(int opt, unsigned long addr, error = -EINVAL ; -down_read (&mm->mmap_sem); +down_write (&mm->mmap_sem); vma =find_vma (mm, addr);switch (opt) {
@@ -2033,7 +2033,7 @@ static int prctl_set_mm(int opt, unsigned long addr, error =0 ; out: -up_read (&mm->mmap_sem); +up_write (&mm->mmap_sem);return error; }
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] usb: cdc-acm: handle unlinked urb in acm read callback
In reply to Sasha LevinFrom: Lu Baolu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 19454462acb1bdef80542061bdc9b410e4ed1ff6 ]
In current acm driver, the bulk-in callback function ignores the URBs unlinked in usb core.
This causes unexpected data loss in some cases. For example, runtime suspend entry will unlinked all urbs and set urb->status to -ENOENT even those urbs might have data not processed yet. Hence, data loss occurs.
This patch lets bulk-in callback function handle unlinked urbs to avoid data loss.
--- drivers/usb/class/cdc-acm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-acm.c +2 -1
@@ -432,7 +432,8 @@ static void acm_read_bulk_callback(struct urb *urb)set_bit (rb->index, &acm->read_urbs_free);dev_dbg (&acm->data->dev,"%s - non-zero urb status: %d\n" , __func__, status); -return ; +if ((status != -ENOENT ) || (urb->actual_length ==0 )) +return ; }usb_mark_last_busy (acm->dev);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] usb: cdc-acm: send zero packet for intel 7260 modem
In reply to Sasha LevinFrom: Lu Baolu <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ffdb1e369a73b380fce95b05f8498d92c43842b4 ]
For Intel 7260 modem, it is needed for host side to send zero packet if the BULK OUT size is equal to USB endpoint max packet length. Otherwise, modem side may still wait for more data and cannot give response to host side.
--- drivers/usb/class/cdc-acm.c | 6 ++++++ drivers/usb/class/cdc-acm.h | 1 + 2 files changed, 7 insertions(+)
drivers/usb/class/cdc-acm.c +6 -0
@@ -1415,6 +1415,8 @@ made_compressed_probe:usb_sndbulkpipe (usb_dev, epwrite->bEndpointAddress), NULL, acm->writesize, acm_write_bulk, snd); snd->urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ; +if (quirks &SEND_ZERO_PACKET ) + snd->urb->transfer_flags |=URB_ZERO_PACKET ; snd->instance = acm; }
@@ -1872,6 +1874,10 @@ static const struct usb_device_id acm_ids[] = { { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, USB_CDC_ACM_PROTO_AT_CDMA) }, + { USB_DEVICE(0x1519, 0x0452), /* Intel 7260 modem */ + .driver_info = SEND_ZERO_PACKET, + }, + { } };
drivers/usb/class/cdc-acm.h +1 -0
@@ -134,3 +134,4 @@ struct acm {#define IGNORE_DEVICE BIT(5)#define QUIRK_CONTROL_LINE_STATE BIT(6)#define CLEAR_HALT_CONDITIONS BIT(7) +#define SEND_ZERO_PACKET BIT(8)
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] wlcore/wl12xx: spi: fix NULL pointer dereference (Oops)
In reply to Sasha LevinFrom: Uri Mashiach <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e47301b06d5a65678690f04c2248fd181db1e59a ]
Fix the below Oops when trying to modprobe wlcore_spi. The oops occurs because the wl1271_power_{off,on}() function doesn't check the power() function pointer.
[ 23.401447] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 23.409954] pgd = c0004000 [ 23.412922] [00000000] *pgd=00000000 [ 23.416693] Internal error: Oops: 80000007 [#1] SMP ARM [ 23.422168] Modules linked in: wl12xx wlcore mac80211 cfg80211
musb_dsps musb_hdrc usbcore usb_common snd_soc_simple_card evdev joydev omap_rng wlcore_spi snd_soc_tlv320aic23_i2c rng_core snd_soc_tlv320aic23 c_can_platform c_can can_dev snd_soc_davinci_mcasp snd_soc_edma snd_soc_omap omap_wdt musb_am335x cpufreq_dt thermal_sys hwmon
[ 23.453253] CPU: 0 PID: 36 Comm: kworker/0:2 Not tainted 4.2.0-00002-g951efee-dirty #233 [ 23.461720] Hardware name: Generic AM33XX (Flattened Device Tree) [ 23.468123] Workqueue: events request_firmware_work_func [ 23.473690] task: de32efc0 ti: de4ee000 task.ti: de4ee000 [ 23.479341] PC is at 0x0 [ 23.482112] LR is at wl12xx_set_power_on+0x28/0x124 [wlcore] [ 23.488074] pc : [<00000000>] lr : [<bf2581f0>] psr: 60000013 [ 23.488074] sp : de4efe50 ip : 00000002 fp : 00000000 [ 23.500162] r10: de7cdd00 r9 : dc848800 r8 : bf27af00 [ 23.505663] r7 : bf27a1a8 r6 : dcbd8a80 r5 : dce0e2e0 r4 : dce0d2e0 [ 23.512536] r3 : 00000000 r2 : 00000000 r1 : 00000001 r0 : dc848810 [ 23.519412] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel [ 23.527109] Control: 10c5387d Table: 9cb78019 DAC: 00000015 [ 23.533160] Process kworker/0:2 (pid: 36, stack limit = 0xde4ee218) [ 23.539760] Stack: (0xde4efe50 to 0xde4f0000)
[...]
[ 23.665030] [<bf2581f0>] (wl12xx_set_power_on [wlcore]) from [<bf25f7ac>] (wlcore_nvs_cb+0x118/0xa4c [wlcore]) [ 23.675604] [<bf25f7ac>] (wlcore_nvs_cb [wlcore]) from [<c04387ec>] (request_firmware_work_func+0x30/0x58) [ 23.685784] [<c04387ec>] (request_firmware_work_func) from [<c0058e2c>] (process_one_work+0x1b4/0x4b4) [ 23.695591] [<c0058e2c>] (process_one_work) from [<c0059168>] (worker_thread+0x3c/0x4a4) [ 23.704124] [<c0059168>] (worker_thread) from [<c005ee68>] (kthread+0xd4/0xf0) [ 23.711747] [<c005ee68>] (kthread) from [<c000f598>] (ret_from_fork+0x14/0x3c) [ 23.719357] Code: bad PC value [ 23.722760] ---[ end trace 981be8510db9b3a9 ]---
Prevent oops by validationg power() pointer value before calling the function.
--- drivers/net/wireless/ti/wlcore/io.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/ti/wlcore/io.h +7 -3
@@ -207,19 +207,23 @@ static inline int __must_check wlcore_write_reg(struct wl1271 *wl, int reg,static inline void wl1271_power_off (struct wl1271 *wl) { -int ret; +int ret =0 ;if (!test_bit (WL1271_FLAG_GPIO_POWER , &wl->flags))return ; - ret = wl->if_ops->power (wl->dev, false); +if (wl->if_ops->power) + ret = wl->if_ops->power (wl->dev, false);if (!ret)clear_bit (WL1271_FLAG_GPIO_POWER , &wl->flags); }static inline int wl1271_power_on (struct wl1271 *wl) { -int ret = wl->if_ops->power (wl->dev, true); +int ret =0 ; + +if (wl->if_ops->power) + ret = wl->if_ops->power (wl->dev, true);if (ret ==0 )set_bit (WL1271_FLAG_GPIO_POWER , &wl->flags);
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] cdc-acm:exclude Samsung phone 04e8:685d
In reply to Sasha LevinFrom: Oliver Neukum <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e912e685f372ab62a2405a1acd923597f524e94a ]
This phone needs to be handled by a specialised firmware tool and is reported to crash irrevocably if cdc-acm takes it.
--- drivers/usb/class/cdc-acm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/class/cdc-acm.c +5 -0
@@ -1851,6 +1851,11 @@ static const struct usb_device_id acm_ids[] = { },#endif +/*Samsung phone in firmware update mode */ + { USB_DEVICE(0x04e8, 0x685d), + .driver_info =IGNORE_DEVICE , + }, + /* Exclude Infineon Flash Loader utility */ { USB_DEVICE(0x058b, 0x0041), .driver_info = IGNORE_DEVICE,
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] usb: hub: do not clear BOS field during reset device
In reply to Sasha LevinFrom: "Du, Changbin" <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d8f00cd685f5c8e0def8593e520a7fef12c22407 ]
In function usb_reset_and_verify_device, the old BOS descriptor may still be used before allocating a new one. (usb_unlocked_disable_lpm function uses it under the situation that it fails to disable lpm.) So we cannot set the udev->bos to NULL before that, just keep what it was. It will be overwrite when allocating a new one.
Crash log:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 IP: [<ffffffff8171f98d>] usb_enable_link_state+0x2d/0x2f0 Call Trace: [<ffffffff8171ed5b>] ? usb_set_lpm_timeout+0x12b/0x140 [<ffffffff8171fcd1>] usb_enable_lpm+0x81/0xa0 [<ffffffff8171fdd8>] usb_disable_lpm+0xa8/0xc0 [<ffffffff8171fe1c>] usb_unlocked_disable_lpm+0x2c/0x50 [<ffffffff81723933>] usb_reset_and_verify_device+0xc3/0x710 [<ffffffff8172c4ed>] ? usb_sg_wait+0x13d/0x190 [<ffffffff81724743>] usb_reset_device+0x133/0x280 [<ffffffff8179ccd1>] usb_stor_port_reset+0x61/0x70 [<ffffffff8179cd68>] usb_stor_invoke_transport+0x88/0x520
--- drivers/usb/core/hub.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/usb/core/hub.c +5 -3
@@ -5346,7 +5346,6 @@ static int usb_reset_and_verify_device(struct usb_device *udev) } bos = udev->bos; - udev->bos =NULL ;for (i =0 ; i <SET_CONFIG_TRIES ; ++i) {
@@ -5439,8 +5438,11 @@ done:usb_set_usb2_hardware_lpm (udev,1 );usb_unlocked_enable_lpm (udev);usb_enable_ltm (udev); -usb_release_bos_descriptor (udev); - udev->bos = bos; +/* release the new BOS descriptor allocated by hub_port_init() */ +if (udev->bos != bos) { +usb_release_bos_descriptor (udev); + udev->bos = bos; + }return 0 ; re_enumerate:
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] USB: visor: fix null-deref at probe
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cac9b50b0d75a1d50d6c056ff65c005f3224c8e0 ]
Fix null-pointer dereference at probe should a (malicious) Treo device lack the expected endpoints.
Specifically, the Treo port-setup hack was dereferencing the bulk-in and interrupt-in urbs without first making sure they had been allocated by core.
--- drivers/usb/serial/visor.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/serial/visor.c +5 -0
@@ -544,6 +544,11 @@ static int treo_attach(struct usb_serial *serial) (serial->num_interrupt_in == 0))return 0 ; +if (serial->num_bulk_in <2 || serial->num_interrupt_in <2 ) { +dev_err (&serial->interface->dev,"missing endpoints\n" ); +return -ENODEV ; + } +/* * It appears that Treos and Kyoceras want to use the * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] mm: soft-offline: check return value in second __get_any_page() call
In reply to Sasha LevinFrom: Naoya Horiguchi <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d96b339f453997f2f08c52da3f41423be48c978f ]
I saw the following BUG_ON triggered in a testcase where a process calls madvise(MADV_SOFT_OFFLINE) on thps, along with a background process that calls migratepages command repeatedly (doing ping-pong among different NUMA nodes) for the first process:
Soft offlining page 0x60000 at 0x700000600000
__get_any_page: 0x60000 free buddy page
page:ffffea0001800000 count:0 mapcount:-127 mapping: (null) index:0x1
flags: 0x1fffc0000000000()
page dumped because: VM_BUG_ON_PAGE(atomic_read(&page->_count) == 0)
------------[ cut here ]------------
kernel BUG at /src/linux-dev/include/linux/mm.h:342!
invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC
Modules linked in: cfg80211 rfkill crc32c_intel serio_raw virtio_balloon i2c_piix4 virtio_blk virtio_net ata_generic pata_acpi
CPU: 3 PID: 3035 Comm: test_alloc_gene Tainted: G O 4.4.0-rc8-v4.4-rc8-160107-1501-00000-rc8+ #74
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
task: ffff88007c63d5c0 ti: ffff88007c210000 task.ti: ffff88007c210000
RIP: 0010:[<ffffffff8118998c>] [<ffffffff8118998c>] put_page+0x5c/0x60
RSP: 0018:ffff88007c213e00 EFLAGS: 00010246
Call Trace:
put_hwpoison_page+0x4e/0x80
soft_offline_page+0x501/0x520
SyS_madvise+0x6bc/0x6f0
entry_SYSCALL_64_fastpath+0x12/0x6a
Code: 8b fc ff ff 5b 5d c3 48 89 df e8 b0 fa ff ff 48 89 df 31 f6 e8 c6 7d ff ff 5b 5d c3 48 c7 c6 08 54 a2 81 48 89 df e8 a4 c5 01 00 <0f> 0b 66 90 66 66 66 66 90 55 48 89 e5 41 55 41 54 53 48 8b 47
RIP [<ffffffff8118998c>] put_page+0x5c/0x60
RSP <ffff88007c213e00>The root cause resides in get_any_page() which retries to get a refcount of the page to be soft-offlined. This function calls put_hwpoison_page(), expecting that the target page is putback to LRU list. But it can be also freed to buddy. So the second check need to care about such case.
--- mm/memory-failure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory-failure.c +1 -1
@@ -1557,7 +1557,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags)* Did it turn free? */ ret =__get_any_page (page, pfn,0 ); -if (!PageLRU (page)) { +if (ret ==1 && !PageLRU (page)) {/* Drop page reference which is from __get_any_page() */ put_page (page); pr_info("soft_offline: %#lx: unknown non LRU page type %lx\n",
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] lib/string_helpers.c: fix infinite loop in string_get_size()
In reply to Sasha LevinFrom: Vitaly Kuznetsov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 62bef58a55dfa8ada2a22b2496c6340468ecd98a ]
Some string_get_size() calls (e.g.:
string_get_size(1, 512, STRING_UNITS_10, ..., ...) string_get_size(15, 64, STRING_UNITS_10, ..., ...)
) result in an infinite loop. The problem is that if size is equal to divisor[units]/blk_size and is smaller than divisor[units] we'll end up with size == 0 when we start doing sf_cap calculations:
For string_get_size(1, 512, STRING_UNITS_10, ..., ...) case:
...
remainder = do_div(size, divisor[units]); -> size is 0, remainder is 1 remainder *= blk_size; -> remainder is 512
...
size *= blk_size; -> size is still 0
size += remainder / divisor[units]; -> size is still 0
The caller causing the issue is sd_read_capacity(), the problem was noticed on Hyper-V, such weird size was reported by host when scanning collides with device removal. This is probably a separate issue worth fixing, this patch is intended to prevent the library routine from infinite looping.
--- lib/string_helpers.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/string_helpers.c +5 -1
@@ -59,7 +59,11 @@ void string_get_size(u64 size, u64 blk_size, const enum string_size_units units, } exp = divisor[units] / (u32 )blk_size; -if (size >= exp) { +/* +* size must be strictly greater than exp here to ensure that remainder +* is greater than divisor[units] coming out of the if below. +*/ +if (size > exp) { remainder =do_div (size, divisor[units]); remainder *= blk_size; i++;
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] USB: serial: visor: fix crash on detecting device without write_urbs
In reply to Sasha LevinFrom: Vladis Dronov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cb3232138e37129e88240a98a1d2aba2187ff57c ]
The visor driver crashes in clie_5_attach() when a specially crafted USB device without bulk-out endpoint is detected. This fix adds a check that the device has proper configuration expected by the driver.
--- drivers/usb/serial/visor.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/serial/visor.c +4 -2
@@ -602,8 +602,10 @@ static int clie_5_attach(struct usb_serial *serial)*/ /* some sanity check */ -if (serial->num_ports <2 ) -return -1 ; +if (serial->num_bulk_out <2 ) { +dev_err (&serial->interface->dev,"missing bulk out endpoints\n" ); +return -ENODEV ; + }/* port 0 now uses the modified endpoint Address */ port = serial->port[0 ];
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] ALSA: seq: Fix incorrect sanity check at snd_seq_oss_synth_cleanup()
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 599151336638d57b98d92338aa59c048e3a3e97d ]
ALSA sequencer OSS emulation code has a sanity check for currently opened devices, but there is a thinko there, eventually it spews warnings and skips the operation wrongly like:
WARNING: CPU: 1 PID: 7573 at sound/core/seq/oss/seq_oss_synth.c:311
Fix this off-by-one error.
--- sound/core/seq/oss/seq_oss_synth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/seq/oss/seq_oss_synth.c +1 -1
@@ -308,7 +308,7 @@ snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp)struct seq_oss_synth *rec;struct seq_oss_synthinfo *info; -if (snd_BUG_ON (dp->max_synthdev >=SNDRV_SEQ_OSS_MAX_SYNTH_DEVS )) +if (snd_BUG_ON (dp->max_synthdev >SNDRV_SEQ_OSS_MAX_SYNTH_DEVS ))return ;for (i =0 ; i < dp->max_synthdev; i++) { info = &dp->synths[i];
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] kernel/panic.c: turn off locks debug before releasing console lock
In reply to Sasha LevinFrom: Vitaly Kuznetsov <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7625b3a0007decf2b135cb47ca67abc78a7b1bc1 ]
Commit 08d78658f393 ("panic: release stale console lock to always get the logbuf printed out") introduced an unwanted bad unlock balance report when panic() is called directly and not from OOPS (e.g. from out_of_memory()). The difference is that in case of OOPS we disable locks debug in oops_enter() and on direct panic call nobody does that.
--- kernel/panic.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/panic.c +4 -1
@@ -151,8 +151,11 @@ void panic(const char *fmt, ...)* We may have ended up stopping the CPU holding the lock (in * smp_send_stop()) while still having some valuable data in the console * buffer. Try to acquire the lock then release it regardless of the -* result. The release will also print the buffers out. +* result. The release will also print the buffers out. Locks debug +* should be disabled to avoid reporting bad unlock balance when +* panic() is not being callled from OOPS. */ +debug_locks_off ();console_trylock ();console_unlock ();
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] USB: serial: option: Adding support for Telit LE922
In reply to Sasha LevinFrom: Daniele Palmas <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ff4e2494dc17b173468e1713fdf6237fd8578bc7 ]
This patch adds support for two PIDs of LE922.
--- drivers/usb/serial/option.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/usb/serial/option.c +16 -0
@@ -271,6 +271,8 @@ static void option_instat_callback(struct urb *urb);#define TELIT_PRODUCT_CC864_SINGLE 0x1006#define TELIT_PRODUCT_DE910_DUAL 0x1010#define TELIT_PRODUCT_UE910_V2 0x1012 +#define TELIT_PRODUCT_LE922_USBCFG0 0x1042 +#define TELIT_PRODUCT_LE922_USBCFG3 0x1043#define TELIT_PRODUCT_LE920 0x1200#define TELIT_PRODUCT_LE910 0x1201
@@ -623,6 +625,16 @@ static const struct option_blacklist_info sierra_mc73xx_blacklist = { .reserved = BIT(8) | BIT(10) | BIT(11), }; +static const struct option_blacklist_info telit_le922_blacklist_usbcfg0 = { + .sendsetup =BIT (2 ), + .reserved =BIT (0 ) |BIT (1 ) |BIT (3 ), +}; + +static const struct option_blacklist_info telit_le922_blacklist_usbcfg3 = { + .sendsetup =BIT (0 ), + .reserved =BIT (1 ) |BIT (2 ) |BIT (3 ), +}; +static const struct usb_device_id option_ids[] = { {USB_DEVICE (OPTION_VENDOR_ID ,OPTION_PRODUCT_COLT ) }, {USB_DEVICE (OPTION_VENDOR_ID ,OPTION_PRODUCT_RICOLA ) },
@@ -1172,6 +1184,10 @@ static const struct usb_device_id option_ids[] = { { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG0), + .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 }, + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG3), + .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
Signature · 1 line
2.5.0
[added to the 4.1 stable tree] ALSA: seq: Degrade the error message for too many opens
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
This patch has been added to the 4.1 stable tree. If you have any objections, please let us know.
===============
[ Upstream commit da10816e3d923565b470fec78a674baba794ed33 ]
ALSA OSS sequencer spews a kernel error message ("ALSA: seq_oss: too many applications") when user-space tries to open more than the limit. This means that it can easily fill the log buffer.
Since it's merely a normal error, it's safe to suppress it via pr_debug() instead.
--- sound/core/seq/oss/seq_oss_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/seq/oss/seq_oss_init.c +1 -1
@@ -202,7 +202,7 @@ snd_seq_oss_open(struct file *file, int level) dp->index = i;if (i >=SNDRV_SEQ_OSS_MAX_CLIENTS ) { -pr_err ("ALSA: seq_oss: too many applications\n" ); +pr_debug ("ALSA: seq_oss: too many applications\n" ); rc = -ENOMEM ; goto _error; }
Signature · 1 line
2.5.0