3.17.3-stable review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 158/319 ext4: Replace open coded mdata csum feature to helper function
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Monakhov <[email protected]>
commit 9aa5d32ba269bec0e7eaba2697a986a7b0bc8528 upstream.
Besides the fact that this replacement improves code readability it also protects from errors caused direct EXT4_S(sb)->s_es manipulation which may result attempt to use uninitialized csum machinery.
#Testcase_BEGIN
IMG=/dev/ram0
MNT=/mnt
mkfs.ext4 $IMG
mount $IMG $MNT
#Enable feature directly on disk, on mounted fs
tune2fs -O metadata_csum $IMG
# Provoke metadata update, likey result in OOPS
touch $MNT/test
umount $MNT
#Testcase_END
# Replacement script
@@
expression E;
@@
- EXT4_HAS_RO_COMPAT_FEATURE(E, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)
+ ext4_has_metadata_csum(E)
https://bugzilla.kernel.org/show_bug.cgi?id=82201
--- fs/ext4/bitmap.c | 12 ++++-------- fs/ext4/ext4.h | 8 ++++++++ fs/ext4/extents.c | 6 ++---- fs/ext4/ialloc.c | 3 +-- fs/ext4/inline.c | 3 +-- fs/ext4/inode.c | 9 +++------ fs/ext4/ioctl.c | 3 +-- fs/ext4/mmp.c | 6 ++---- fs/ext4/namei.c | 39 +++++++++++++-------------------------- fs/ext4/resize.c | 3 +-- fs/ext4/super.c | 15 +++++---------- fs/ext4/xattr.c | 6 ++---- 12 files changed, 43 insertions(+), 70 deletions(-)
fs/ext4/bitmap.c +4 -8
@@ -24,8 +24,7 @@ int ext4_inode_bitmap_csum_verify(struct__u32 provided, calculated;struct ext4_sb_info *sbi =EXT4_SB (sb); -if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (sb))return 1 ; provided =le16_to_cpu (gdp->bg_inode_bitmap_csum_lo);
@@ -46,8 +45,7 @@ void ext4_inode_bitmap_csum_set(struct s__u32 csum;struct ext4_sb_info *sbi =EXT4_SB (sb); -if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (sb))return ; csum =ext4_chksum (sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
@@ -65,8 +63,7 @@ int ext4_block_bitmap_csum_verify(structstruct ext4_sb_info *sbi =EXT4_SB (sb);int sz =EXT4_CLUSTERS_PER_GROUP (sb) /8 ; -if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (sb))return 1 ; provided =le16_to_cpu (gdp->bg_block_bitmap_csum_lo);
@@ -91,8 +88,7 @@ void ext4_block_bitmap_csum_set(struct s__u32 csum;struct ext4_sb_info *sbi =EXT4_SB (sb); -if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (sb))return ; csum =ext4_chksum (sbi, sbi->s_csum_seed, (__u8 *)bh->b_data, sz);
fs/ext4/ext4.h +8 -0
@@ -2337,6 +2337,14 @@ static inline int ext4_has_group_desc_cs EXT4_FEATURE_RO_COMPAT_METADATA_CSUM); } +static inline int ext4_has_metadata_csum (struct super_block *sb) +{ +WARN_ON_ONCE (EXT4_HAS_RO_COMPAT_FEATURE (sb, +EXT4_FEATURE_RO_COMPAT_METADATA_CSUM ) && + !EXT4_SB (sb)->s_chksum_driver); + +return (EXT4_SB (sb)->s_chksum_driver !=NULL ); +}static inline ext4_fsblk_t ext4_blocks_count (struct ext4_super_block *es) { return ((ext4_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
fs/ext4/extents.c +2 -4
@@ -73,8 +73,7 @@ static int ext4_extent_block_csum_verify {struct ext4_extent_tail *et; -if (!EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (inode->i_sb))return 1 ; et =find_ext4_extent_tail (eh);
@@ -88,8 +87,7 @@ static void ext4_extent_block_csum_set(s {struct ext4_extent_tail *et; -if (!EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (inode->i_sb))return ; et =find_ext4_extent_tail (eh);
fs/ext4/ialloc.c +1 -2
@@ -1011,8 +1011,7 @@ got:spin_unlock (&sbi->s_next_gen_lock);/* Precompute checksum seed for inode metadata */ -if (EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) { +if (ext4_has_metadata_csum (sb)) {__u32 csum;__le32 inum =cpu_to_le32 (inode->i_ino);__le32 gen =cpu_to_le32 (inode->i_generation);
fs/ext4/inline.c +1 -2
@@ -1126,8 +1126,7 @@ static int ext4_finish_convert_inline_dimemcpy ((void *)de, buf +EXT4_INLINE_DOTDOT_SIZE , inline_size -EXT4_INLINE_DOTDOT_SIZE ); -if (EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (ext4_has_metadata_csum (inode->i_sb)) csum_size =sizeof (struct ext4_dir_entry_tail ); inode->i_size = inode->i_sb->s_blocksize;
fs/ext4/inode.c +3 -6
@@ -83,8 +83,7 @@ static int ext4_inode_csum_verify(structif (EXT4_SB (inode->i_sb)->s_es->s_creator_os !=cpu_to_le32 (EXT4_OS_LINUX ) || - !EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) + !ext4_has_metadata_csum (inode->i_sb))return 1 ; provided =le16_to_cpu (raw->i_checksum_lo);
@@ -105,8 +104,7 @@ static void ext4_inode_csum_set(struct iif (EXT4_SB (inode->i_sb)->s_es->s_creator_os !=cpu_to_le32 (EXT4_OS_LINUX ) || - !EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) + !ext4_has_metadata_csum (inode->i_sb))return ; csum =ext4_inode_csum (inode, raw, ei);
@@ -3950,8 +3948,7 @@ struct inode *ext4_iget(struct super_blo ei->i_extra_isize =0 ;/* Precompute checksum seed for inode metadata */ -if (EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) { +if (ext4_has_metadata_csum (sb)) {struct ext4_sb_info *sbi =EXT4_SB (inode->i_sb);__u32 csum;__le32 inum =cpu_to_le32 (inode->i_ino);
fs/ext4/ioctl.c +1 -2
@@ -331,8 +331,7 @@ flags_out:if (!inode_owner_or_capable (inode))return -EPERM ; -if (EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) { +if (ext4_has_metadata_csum (inode->i_sb)) {ext4_warning (sb,"Setting inode version is not " "supported with metadata_csum enabled." );return -ENOTTY ;
fs/ext4/mmp.c +2 -4
@@ -20,8 +20,7 @@ static __le32 ext4_mmp_csum(struct superstatic int ext4_mmp_csum_verify (struct super_block *sb,struct mmp_struct *mmp) { -if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (sb))return 1 ;return mmp->mmp_checksum ==ext4_mmp_csum (sb, mmp);
@@ -29,8 +28,7 @@ static int ext4_mmp_csum_verify(struct sstatic void ext4_mmp_csum_set (struct super_block *sb,struct mmp_struct *mmp) { -if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (sb))return ; mmp->mmp_checksum =ext4_mmp_csum (sb, mmp);
fs/ext4/namei.c +13 -26
@@ -124,8 +124,7 @@ static struct buffer_head *__ext4_read_d "directory leaf block found instead of index block");return ERR_PTR (-EIO ); } -if (!EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM ) || +if (!ext4_has_metadata_csum (inode->i_sb) ||buffer_verified (bh))return bh;
@@ -340,8 +339,7 @@ int ext4_dirent_csum_verify(struct inode {struct ext4_dir_entry_tail *t; -if (!EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (inode->i_sb))return 1 ; t =get_dirent_tail (inode, dirent);
@@ -362,8 +360,7 @@ static void ext4_dirent_csum_set(struct {struct ext4_dir_entry_tail *t; -if (!EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (inode->i_sb))return ; t =get_dirent_tail (inode, dirent);
@@ -438,8 +435,7 @@ static int ext4_dx_csum_verify(struct instruct dx_tail *t;int count_offset, limit, count; -if (!EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (inode->i_sb))return 1 ; c =get_dx_countlimit (inode, dirent, &count_offset);
@@ -468,8 +464,7 @@ static void ext4_dx_csum_set(struct inodstruct dx_tail *t;int count_offset, limit, count; -if (!EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (inode->i_sb))return ; c =get_dx_countlimit (inode, dirent, &count_offset);
@@ -557,8 +552,7 @@ static inline unsigned dx_root_limit(strunsigned entry_space = dir->i_sb->s_blocksize -EXT4_DIR_REC_LEN (1 ) -EXT4_DIR_REC_LEN (2 ) - infosize; -if (EXT4_HAS_RO_COMPAT_FEATURE (dir->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (ext4_has_metadata_csum (dir->i_sb)) entry_space -=sizeof (struct dx_tail );return entry_space /sizeof (struct dx_entry ); }
@@ -567,8 +561,7 @@ static inline unsigned dx_node_limit(str {unsigned entry_space = dir->i_sb->s_blocksize -EXT4_DIR_REC_LEN (0 ); -if (EXT4_HAS_RO_COMPAT_FEATURE (dir->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (ext4_has_metadata_csum (dir->i_sb)) entry_space -=sizeof (struct dx_tail );return entry_space /sizeof (struct dx_entry ); }
@@ -1548,8 +1541,7 @@ static struct ext4_dir_entry_2 *do_splitint csum_size =0 ;int err =0 , i; -if (EXT4_HAS_RO_COMPAT_FEATURE (dir->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (ext4_has_metadata_csum (dir->i_sb)) csum_size =sizeof (struct ext4_dir_entry_tail ); bh2 =ext4_append (handle, dir, &newblock);
@@ -1718,8 +1710,7 @@ static int add_dirent_to_buf(handle_t *hint csum_size =0 ;int err; -if (EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (ext4_has_metadata_csum (inode->i_sb)) csum_size =sizeof (struct ext4_dir_entry_tail );if (!de) {
@@ -1786,8 +1777,7 @@ static int make_indexed_dir(handle_t *hastruct fake_dirent *fde;int csum_size =0 ; -if (EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (ext4_has_metadata_csum (inode->i_sb)) csum_size =sizeof (struct ext4_dir_entry_tail ); blocksize = dir->i_sb->s_blocksize;
@@ -1904,8 +1894,7 @@ static int ext4_add_entry(handle_t *handext4_lblk_t block, blocks;int csum_size =0 ; -if (EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (ext4_has_metadata_csum (inode->i_sb)) csum_size =sizeof (struct ext4_dir_entry_tail ); sb = dir->i_sb;
@@ -2167,8 +2156,7 @@ static int ext4_delete_entry(handle_t *hreturn err; } -if (EXT4_HAS_RO_COMPAT_FEATURE (dir->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (ext4_has_metadata_csum (dir->i_sb)) csum_size =sizeof (struct ext4_dir_entry_tail );BUFFER_TRACE (bh,"get_write_access" );
@@ -2387,8 +2375,7 @@ static int ext4_init_new_dir(handle_t *hint csum_size =0 ;int err; -if (EXT4_HAS_RO_COMPAT_FEATURE (dir->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (ext4_has_metadata_csum (dir->i_sb)) csum_size =sizeof (struct ext4_dir_entry_tail );if (ext4_test_inode_state (inode,EXT4_STATE_MAY_INLINE_DATA )) {
fs/ext4/resize.c +1 -2
@@ -1212,8 +1212,7 @@ static int ext4_set_bitmap_checksums(str {struct buffer_head *bh; -if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (sb))return 0 ; bh =ext4_get_bitmap (sb, group_data->inode_bitmap);
fs/ext4/super.c +5 -10
@@ -141,8 +141,7 @@ static __le32 ext4_superblock_csum(strucstatic int ext4_superblock_csum_verify (struct super_block *sb,struct ext4_super_block *es) { -if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (sb))return 1 ;return es->s_checksum ==ext4_superblock_csum (sb, es);
@@ -152,8 +151,7 @@ void ext4_superblock_csum_set(struct sup {struct ext4_super_block *es =EXT4_SB (sb)->s_es; -if (!EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (sb))return ; es->s_checksum =ext4_superblock_csum (sb, es);
@@ -2009,8 +2007,7 @@ static __le16 ext4_group_desc_csum(struc__u16 crc =0 ;__le32 le_group =cpu_to_le32 (block_group); -if ((sbi->s_es->s_feature_ro_compat & -cpu_to_le32 (EXT4_FEATURE_RO_COMPAT_METADATA_CSUM ))) { +if (ext4_has_metadata_csum (sbi->s_sb)) {/* Use new metadata_csum algorithm */ __le16 save_csum;__u32 csum32;
@@ -3172,8 +3169,7 @@ static int set_journal_csum_feature_set(int compat, incompat;struct ext4_sb_info *sbi =EXT4_SB (sb); -if (EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) { +if (ext4_has_metadata_csum (sb)) {/* journal checksum v3 */ compat =0 ; incompat =JBD2_FEATURE_INCOMPAT_CSUM_V3 ;
@@ -3480,8 +3476,7 @@ static int ext4_fill_super(struct super_ }/* Precompute checksum seed for all metadata */ -if (EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (ext4_has_metadata_csum (sb)) sbi->s_csum_seed =ext4_chksum (sbi, ~0 , es->s_uuid,sizeof (es->s_uuid));
fs/ext4/xattr.c +2 -4
@@ -142,8 +142,7 @@ static int ext4_xattr_block_csum_verify( sector_t block_nr, struct ext4_xattr_header *hdr) { - if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb, - EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) && + if (ext4_has_metadata_csum(inode->i_sb) && (hdr->h_checksum != ext4_xattr_block_csum(inode, block_nr, hdr))) return 0;return 1 ;
@@ -153,8 +152,7 @@ static void ext4_xattr_block_csum_set(st sector_t block_nr, struct ext4_xattr_header *hdr) { -if (!EXT4_HAS_RO_COMPAT_FEATURE (inode->i_sb, -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM )) +if (!ext4_has_metadata_csum (inode->i_sb))return ; hdr->h_checksum =ext4_xattr_block_csum (inode, block_nr, hdr);
Greg Kroah-Hartman
maintainerPATCH 159/319 ext4: move error report out of atomic context in ext4_init_block_bitmap()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Monakhov <[email protected]>
commit aef4885ae14f1df75b58395c5314d71f613d26d9 upstream.
Error report likely result in IO so it is bad idea to do it from atomic context.
This patch should fix following issue:
BUG: sleeping function called from invalid context at include/linux/buffer_head.h:349
in_atomic(): 1, irqs_disabled(): 0, pid: 137, name: kworker/u128:1
5 locks held by kworker/u128:1/137:
#0: ("writeback"){......}, at: [<ffffffff81085618>] process_one_work+0x228/0x4d0
#1: ((&(&wb->dwork)->work)){......}, at: [<ffffffff81085618>] process_one_work+0x228/0x4d0
#2: (jbd2_handle){......}, at: [<ffffffff81242622>] start_this_handle+0x712/0x7b0
#3: (&ei->i_data_sem){......}, at: [<ffffffff811fa387>] ext4_map_blocks+0x297/0x430
#4: (&(&bgl->locks[i].lock)->rlock){......}, at: [<ffffffff811f3180>] ext4_read_block_bitmap_nowait+0x5d0/0x630
CPU: 3 PID: 137 Comm: kworker/u128:1 Not tainted 3.17.0-rc2-00184-g82752e4 #165
Hardware name: Intel Corporation W2600CR/W2600CR, BIOS SE5C600.86B.99.99.x028.061320111235 06/13/2011
Workqueue: writeback bdi_writeback_workfn (flush-1:0)
0000000000000411 ffff880813777288 ffffffff815c7fdc ffff880813777288
ffff880813a8bba0 ffff8808137772a8 ffffffff8108fb30 ffff880803e01e38
ffff880803e01e38 ffff8808137772c8 ffffffff811a8d53 ffff88080ecc6000
Call Trace:
[<ffffffff815c7fdc>] dump_stack+0x51/0x6d
[<ffffffff8108fb30>] __might_sleep+0xf0/0x100
[<ffffffff811a8d53>] __sync_dirty_buffer+0x43/0xe0
[<ffffffff811a8e03>] sync_dirty_buffer+0x13/0x20
[<ffffffff8120f581>] ext4_commit_super+0x1d1/0x230
[<ffffffff8120fa03>] save_error_info+0x23/0x30
[<ffffffff8120fd06>] __ext4_error+0xb6/0xd0
[<ffffffff8120f260>] ? ext4_group_desc_csum+0x140/0x190
[<ffffffff811f2d8c>] ext4_read_block_bitmap_nowait+0x1dc/0x630
[<ffffffff8122e23a>] ext4_mb_init_cache+0x21a/0x8f0
[<ffffffff8113ae95>] ? lru_cache_add+0x55/0x60
[<ffffffff8112e16c>] ? add_to_page_cache_lru+0x6c/0x80
[<ffffffff8122eaa0>] ext4_mb_init_group+0x190/0x280
[<ffffffff8122ec51>] ext4_mb_good_group+0xc1/0x190
[<ffffffff8123309a>] ext4_mb_regular_allocator+0x17a/0x410
[<ffffffff8122c821>] ? ext4_mb_use_preallocated+0x31/0x380
[<ffffffff81233535>] ? ext4_mb_new_blocks+0x205/0x8e0
[<ffffffff8116ed5c>] ? kmem_cache_alloc+0xfc/0x180
[<ffffffff812335b0>] ext4_mb_new_blocks+0x280/0x8e0
[<ffffffff8116f2c4>] ? __kmalloc+0x144/0x1c0
[<ffffffff81221797>] ? ext4_find_extent+0x97/0x320
[<ffffffff812257f4>] ext4_ext_map_blocks+0xbc4/0x1050
[<ffffffff811fa387>] ? ext4_map_blocks+0x297/0x430
[<ffffffff811fa3ab>] ext4_map_blocks+0x2bb/0x430
[<ffffffff81200e43>] ? ext4_init_io_end+0x23/0x50
[<ffffffff811feb44>] ext4_writepages+0x564/0xaf0
[<ffffffff815cde3b>] ? _raw_spin_unlock+0x2b/0x40
[<ffffffff810ac7bd>] ? lock_release_non_nested+0x2fd/0x3c0
[<ffffffff811a009e>] ? writeback_sb_inodes+0x10e/0x490
[<ffffffff811a009e>] ? writeback_sb_inodes+0x10e/0x490
[<ffffffff811377e3>] do_writepages+0x23/0x40
[<ffffffff8119c8ce>] __writeback_single_inode+0x9e/0x280
[<ffffffff811a026b>] writeback_sb_inodes+0x2db/0x490
[<ffffffff811a0664>] wb_writeback+0x174/0x2d0
[<ffffffff810ac359>] ? lock_release_holdtime+0x29/0x190
[<ffffffff811a0863>] wb_do_writeback+0xa3/0x200
[<ffffffff811a0a40>] bdi_writeback_workfn+0x80/0x230
[<ffffffff81085618>] ? process_one_work+0x228/0x4d0
[<ffffffff810856cd>] process_one_work+0x2dd/0x4d0
[<ffffffff81085618>] ? process_one_work+0x228/0x4d0
[<ffffffff81085c1d>] worker_thread+0x35d/0x460
[<ffffffff810858c0>] ? process_one_work+0x4d0/0x4d0
[<ffffffff810858c0>] ? process_one_work+0x4d0/0x4d0
[<ffffffff8108a885>] kthread+0xf5/0x100
[<ffffffff810990e5>] ? local_clock+0x25/0x30
[<ffffffff8108a790>] ? __init_kthread_worker+0x70/0x70
[<ffffffff815ce2ac>] ret_from_fork+0x7c/0xb0
[<ffffffff8108a790>] ? __init_kthread_work--- fs/ext4/balloc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/ext4/balloc.c +8 -4
@@ -176,7 +176,7 @@ static unsigned int num_clusters_in_grou }/* Initializes an uninitialized block bitmap */ -static void ext4_init_block_bitmap (struct super_block *sb, +static int ext4_init_block_bitmap (struct super_block *sb,struct buffer_head *bh,ext4_group_t block_group,struct ext4_group_desc *gdp)
@@ -192,7 +192,6 @@ static void ext4_init_block_bitmap(struc/* If checksum is bad mark all blocks used to prevent allocation * essentially implementing a per-group read-only flag. */ if (!ext4_group_desc_csum_verify (sb, block_group, gdp)) { -ext4_error (sb,"Checksum bad for group %u" , block_group); grp =ext4_get_group_info (sb, block_group);if (!EXT4_MB_GRP_BBITMAP_CORRUPT (grp)) percpu_counter_sub(&sbi->s_freeclusters_counter,
@@ -205,7 +204,7 @@ static void ext4_init_block_bitmap(struc count); }set_bit (EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT , &grp->bb_state); -return ; +return -EIO ; }memset (bh->b_data,0 , sb->s_blocksize);
@@ -243,6 +242,7 @@ static void ext4_init_block_bitmap(struc sb->s_blocksize * 8, bh->b_data);ext4_block_bitmap_csum_set (sb, block_group, gdp, bh);ext4_group_desc_csum_set (sb, block_group, gdp); +return 0 ; }/* Return the number of free blocks in a block group. It is used when
@@ -438,11 +438,15 @@ ext4_read_block_bitmap_nowait(struct sup }ext4_lock_group (sb, block_group);if (desc->bg_flags &cpu_to_le16 (EXT4_BG_BLOCK_UNINIT )) { -ext4_init_block_bitmap (sb, bh, block_group, desc); +int err; + + err =ext4_init_block_bitmap (sb, bh, block_group, desc);set_bitmap_uptodate (bh);set_buffer_uptodate (bh);ext4_unlock_group (sb, block_group);unlock_buffer (bh); +if (err) +ext4_error (sb,"Checksum bad for grp %u" , block_group);return bh; }ext4_unlock_group (sb, block_group);
Greg Kroah-Hartman
maintainerPATCH 160/319 ext4: check s_chksum_driver when looking for bg csum presence
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Darrick J. Wong" <[email protected]>
commit 813d32f91333e4c33d5a19b67167c4bae42dae75 upstream.
Convert the ext4_has_group_desc_csum predicate to look for a checksum driver instead of the metadata_csum flag and change the bg checksum calculation function to look for GDT_CSUM before taking the crc16 path.
Without this patch, if we mount with ^uninit_bg,^metadata_csum and later metadata_csum gets turned on by accident, the block group checksum functions will incorrectly assume that checksumming is enabled (metadata_csum) but that crc16 should be used (!s_chksum_driver). This is totally wrong, so fix the predicate and the checksum formula selection.
(Granted, if the metadata_csum feature bit gets enabled on a live FS then something underhanded is going on, but we could at least avoid writing garbage into the on-disk fields.)
--- fs/ext4/ext4.h | 4 ++-- fs/ext4/super.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-)
fs/ext4/ext4.h +2 -2
@@ -2333,8 +2333,8 @@ extern int ext4_register_li_request(strustatic inline int ext4_has_group_desc_csum (struct super_block *sb) {return EXT4_HAS_RO_COMPAT_FEATURE (sb, -EXT4_FEATURE_RO_COMPAT_GDT_CSUM | -EXT4_FEATURE_RO_COMPAT_METADATA_CSUM ); +EXT4_FEATURE_RO_COMPAT_GDT_CSUM ) || + (EXT4_SB (sb)->s_chksum_driver !=NULL ); }static inline int ext4_has_metadata_csum (struct super_block *sb)
fs/ext4/super.c +4 -0
@@ -2025,6 +2025,10 @@ static __le16 ext4_group_desc_csum(struc }/* old crc16 code */ +if (!(sbi->s_es->s_feature_ro_compat & +cpu_to_le32 (EXT4_FEATURE_RO_COMPAT_GDT_CSUM ))) +return 0 ; + offset = offsetof(struct ext4_group_desc , bg_checksum); crc =crc16 (~0 , sbi->s_es->s_uuid,sizeof (sbi->s_es->s_uuid));
Greg Kroah-Hartman
maintainerPATCH 161/319 ext4: fix oops when loading block bitmap failed
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 599a9b77ab289d85c2d5c8607624efbe1f552b0f upstream.
When we fail to load block bitmap in __ext4_new_inode() we will dereference NULL pointer in ext4_journal_get_write_access(). So check for error from ext4_read_block_bitmap().
Coverity-id: 989065
--- fs/ext4/ialloc.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ext4/ialloc.c +4 -0
@@ -887,6 +887,10 @@ got:struct buffer_head *block_bitmap_bh; block_bitmap_bh =ext4_read_block_bitmap (sb, group); +if (!block_bitmap_bh) { + err = -EIO ; + goto out; + }BUFFER_TRACE (block_bitmap_bh,"get block bitmap access" ); err =ext4_journal_get_write_access (handle, block_bitmap_bh);if (err) {
Greg Kroah-Hartman
maintainerPATCH 162/319 ext4: fix overflow when updating superblock backups after resize
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 9378c6768e4fca48971e7b6a9075bc006eda981d upstream.
When there are no meta block groups update_backups() will compute the backup block in 32-bit arithmetics thus possibly overflowing the block number and corrupting the filesystem. OTOH filesystems without meta block groups larger than 16 TB should be rare. Fix the problem by doing the counting in 64-bit arithmetics.
Coverity-id: 741252
--- fs/ext4/resize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/resize.c +1 -1
@@ -1081,7 +1081,7 @@ static void update_backups(struct super_break ;if (meta_bg ==0 ) - backup_block = group * bpg + blk_off; + backup_block = ((ext4_fsblk_t )group) * bpg + blk_off;else backup_block = (ext4_group_first_block_no (sb, group) +ext4_bg_has_super (sb, group));
Greg Kroah-Hartman
maintainerPATCH 163/319 ext4: enable journal checksum when metadata checksum feature enabled
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Darrick J. Wong" <[email protected]>
commit 98c1a7593fa355fda7f5a5940c8bf5326ca964ba upstream.
If metadata checksumming is turned on for the FS, we need to tell the journal to use checksumming too.
--- fs/ext4/super.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ext4/super.c +4 -0
@@ -3498,6 +3498,10 @@ static int ext4_fill_super(struct super_#ifdef CONFIG_EXT4_FS_POSIX_ACL set_opt (sb,POSIX_ACL );#endif +/* don't forget to enable journal_csum when metadata_csum is enabled. */ +if (ext4_has_metadata_csum (sb)) +set_opt (sb,JOURNAL_CHECKSUM ); +if ((def_mount_opts &EXT4_DEFM_JMODE ) ==EXT4_DEFM_JMODE_DATA )set_opt (sb,JOURNAL_DATA );else if ((def_mount_opts &EXT4_DEFM_JMODE ) ==EXT4_DEFM_JMODE_ORDERED )
Greg Kroah-Hartman
maintainerPATCH 164/319 ext4: prevent bugon on race between write/fcntl
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Monakhov <[email protected]>
commit a41537e69b4aa43f0fea02498c2595a81267383b upstream.
O_DIRECT flags can be toggeled via fcntl(F_SETFL). But this value checked twice inside ext4_file_write_iter() and __generic_file_write() which result in BUG_ON inside ext4_direct_IO.
Let's initialize iocb->private unconditionally.
TESTCASE: xfstest:generic/036 https://patchwork.ozlabs.org/patch/402445/
#TYPICAL STACK TRACE:
kernel BUG at fs/ext4/inode.c:2960!
invalid opcode: 0000 [#1] SMP
Modules linked in: brd iTCO_wdt lpc_ich mfd_core igb ptp dm_mirror dm_region_hash dm_log dm_mod CPU: 6 PID: 5505 Comm: aio-dio-fcntl-r Not tainted 3.17.0-rc2-00176-gff5c017 #161 Hardware name: Intel Corporation W2600CR/W2600CR, BIOS SE5C600.86B.99.99.x028.061320111235 06/13/2011 task: ffff88080e95a7c0 ti: ffff88080f908000 task.ti: ffff88080f908000 RIP: 0010:[<ffffffff811fabf2>] [<ffffffff811fabf2>] ext4_direct_IO+0x162/0x3d0 RSP: 0018:ffff88080f90bb58 EFLAGS: 00010246 RAX: 0000000000000400 RBX: ffff88080fdb2a28 RCX: 00000000a802c818 RDX: 0000040000080000 RSI: ffff88080d8aeb80 RDI: 0000000000000001 RBP: ffff88080f90bbc8 R08: 0000000000000000 R09: 0000000000001581 R10: 0000000000000000 R11: 0000000000000000 R12: ffff88080d8aeb80 R13: ffff88080f90bbf8 R14: ffff88080fdb28c8 R15: ffff88080fdb2a28 FS: 00007f23b2055700(0000) GS:ffff880818400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f23b2045000 CR3: 000000080cedf000 CR4: 00000000000407e0 Stack: ffff88080f90bb98 0000000000000000 7ffffffffffffffe ffff88080fdb2c30 0000000000000200 0000000000000200 0000000000000001 0000000000000200 ffff88080f90bbc8 ffff88080fdb2c30 ffff88080f90be08 0000000000000200 Call Trace: [<ffffffff8112ca9d>] generic_file_direct_write+0xed/0x180 [<ffffffff8112f2b2>] __generic_file_write_iter+0x222/0x370 [<ffffffff811f495b>] ext4_file_write_iter+0x34b/0x400 [<ffffffff811bd709>] ? aio_run_iocb+0x239/0x410 [<ffffffff811bd709>] ? aio_run_iocb+0x239/0x410 [<ffffffff810990e5>] ? local_clock+0x25/0x30 [<ffffffff810abd94>] ? __lock_acquire+0x274/0x700 [<ffffffff811f4610>] ? ext4_unwritten_wait+0xb0/0xb0 [<ffffffff811bd756>] aio_run_iocb+0x286/0x410 [<ffffffff810990e5>] ? local_clock+0x25/0x30 [<ffffffff810ac359>] ? lock_release_holdtime+0x29/0x190 [<ffffffff811bc05b>] ? lookup_ioctx+0x4b/0xf0 [<ffffffff811bde3b>] do_io_submit+0x55b/0x740 [<ffffffff811bdcaa>] ? do_io_submit+0x3ca/0x740 [<ffffffff811be030>] SyS_io_submit+0x10/0x20 [<ffffffff815ce192>] system_call_fastpath+0x16/0x1b Code: 01 48 8b 80 f0 01 00 00 48 8b 18 49 8b 45 10 0f 85 f1 01 00 00 48 03 45 c8 48 3b 43 48 0f 8f e3 01 00 00 49 83 7c
24 18 00 75 04 <0f> 0b eb fe f0 ff 83 ec 01 00 00 49 8b 44 24 18 8b 00 85 c0 89 RIP [<ffffffff811fabf2>] ext4_direct_IO+0x162/0x3d0
RSP <ffff88080f90bb58>
--- fs/ext4/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/file.c +1 -1
@@ -137,10 +137,10 @@ ext4_file_write_iter(struct kiocb *iocb,iov_iter_truncate (from, sbi->s_bitmap_maxbytes - pos); } + iocb->private = &overwrite;if (o_direct) {blk_start_plug (&plug); - iocb->private = &overwrite;/* check whether we do a DIO overwrite or not */ if (ext4_should_dioread_nolock(inode) && !aio_mutex &&
Greg Kroah-Hartman
maintainerPATCH 165/319 futex: Fix a race condition between REQUEUE_PI and task death
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Silverman <[email protected]>
commit 30a6b8031fe14031ab27c1fa3483cb9780e7f63c upstream.
free_pi_state and exit_pi_state_list both clean up futex_pi_state's. exit_pi_state_list takes the hb lock first, and most callers of free_pi_state do too. requeue_pi doesn't, which means free_pi_state can free the pi_state out from under exit_pi_state_list. For example:
task A | task B
exit_pi_state_list |
pi_state = |
curr->pi_state_list->next |
| futex_requeue(requeue_pi=1)
| // pi_state is the same as
| // the one in task A
| free_pi_state(pi_state)
| list_del_init(&pi_state->list)
| kfree(pi_state)
list_del_init(&pi_state->list) |Move the free_pi_state calls in requeue_pi to before it drops the hb locks which it's already holding.
[ tglx: Removed a pointless free_pi_state() call and the hb->lock held
debugging. The latter comes via a seperate patch ]
--- kernel/futex.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
kernel/futex.c +11 -11
@@ -641,8 +641,14 @@ static struct futex_pi_state * alloc_pi_return pi_state; } +/* +* Must be called with the hb lock held. +*/ static void free_pi_state (struct futex_pi_state *pi_state) { +if (!pi_state) +return ; +if (!atomic_dec_and_test (&pi_state->refcount))return ;
@@ -1521,15 +1527,6 @@ static int futex_requeue(u32 __user *uad } retry: -if (pi_state !=NULL ) { -/* -* We will have to lookup the pi_state again, so free this one -* to keep the accounting correct. -*/ -free_pi_state (pi_state); - pi_state =NULL ; - } - ret =get_futex_key (uaddr1, flags &FLAGS_SHARED , &key1,VERIFY_READ );if (unlikely (ret !=0 )) goto out;
@@ -1619,6 +1616,8 @@ retry_private:case 0 :break ;case -EFAULT : +free_pi_state (pi_state); + pi_state =NULL ;double_unlock_hb (hb1, hb2);hb_waiters_dec (hb2);put_futex_key (&key2);
@@ -1634,6 +1633,8 @@ retry_private:* exit to complete. * - The user space value changed. */ +free_pi_state (pi_state); + pi_state =NULL ;double_unlock_hb (hb1, hb2);hb_waiters_dec (hb2);put_futex_key (&key2);
@@ -1710,6 +1711,7 @@ retry_private: } out_unlock: +free_pi_state (pi_state);double_unlock_hb (hb1, hb2);hb_waiters_dec (hb2);
@@ -1727,8 +1729,6 @@ out_put_keys: out_put_key1:put_futex_key (&key1); out: -if (pi_state !=NULL ) -free_pi_state (pi_state);return ret ? ret : task_count; }
Greg Kroah-Hartman
maintainerPATCH 166/319 drm/nouveau: fix regression on agp boards
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Skeggs <[email protected]>
commit 67e26e41ff8aa514826dae79f0b10169b5ba93b4 upstream.
Extends the fix in f2f9a2cbaf019481feefe231f996d3602612fa99 to also workaround permission issues noticed by people using AGP systems.
--- drivers/gpu/drm/nouveau/nouveau_chan.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_chan.c +9 -3
@@ -400,15 +400,20 @@ nouveau_channel_new(struct nouveau_drm * struct nouveau_channel **pchan) {struct nouveau_cli *cli = (void *)nvif_client (&device->base); +bool super;int ret; +/* hack until fencenv50 is fixed, and agp access relaxed */ + super = cli->base.super; + cli->base.super = true; + ret =nouveau_channel_ind (drm, device, handle, arg0, pchan);if (ret) {NV_PRINTK (debug, cli,"ib channel create, %d\n" , ret); ret =nouveau_channel_dma (drm, device, handle, pchan);if (ret) {NV_PRINTK (debug, cli,"dma channel create, %d\n" , ret); -return ret; + goto done; } }
@@ -416,8 +421,9 @@ nouveau_channel_new(struct nouveau_drm *if (ret) {NV_PRINTK (error, cli,"channel failed to initialise, %d\n" , ret);nouveau_channel_del (pchan); -return ret; } -return 0 ; +done: + cli->base.super = super; +return ret; }
Greg Kroah-Hartman
maintainerPATCH 167/319 drm/i915: intel_backlight scale() math WA
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: "U. Artie Eoff" <[email protected]>
commit 673e7bbdb3920b62cfc6c710bea626b0a9b0f43a upstream.
Improper truncated integer division in the scale() function causes actual_brightness != brightness. This (partial) work-around should be sufficient for a majority of use-cases, but it is by no means a complete solution.
TODO: Determine how best to scale "user" values to "hw" values, and vice-versa, when the ranges are of different sizes. That would be a buggy scenario even with this work-around.
The issue was introduced in the following (v3.17-rc1) commit:
6dda730 drm/i915: respect the VBT minimum backlight brightness
Note that for easier backporting this commit adds a duplicated macro. A follow-up cleanup patch rectifies this for 3.18+
v2: (thanks to Chris Wilson) clarify commit message, use rounded division macro
v3: -DIV_ROUND_CLOSEST() fails to build with CONFIG_X86_32=y. (Jani)
-Use DIV_ROUND_CLOSEST_ULL() instead. (Damien)
-v1 and v2 originally authored by Joe Konno.
--- drivers/gpu/drm/i915/intel_panel.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_panel.c +5 -3
@@ -398,6 +398,9 @@ intel_panel_detect(struct drm_device *de } } +#define DIV_ROUND_CLOSEST_ULL (ll, d) \ +({ unsigned long long _tmp = (ll)+(d)/2; do_div(_tmp, d); _tmp; }) +/** * scale - scale values from one range to another *
@@ -419,9 +422,8 @@ static uint32_t scale(uint32_t source_va source_val =clamp (source_val, source_min, source_max);/* avoid overflows */ - target_val = (uint64_t )(source_val - source_min) * - (target_max - target_min); -do_div (target_val, source_max - source_min); + target_val =DIV_ROUND_CLOSEST_ULL ((uint64_t )(source_val - source_min) * + (target_max - target_min), source_max - source_min); target_val += target_min;return target_val;
Greg Kroah-Hartman
maintainerPATCH 169/319 drm/radeon: fix speaker allocation setup
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 4910403836ded89803fab201d4b5caaa85de3a89 upstream.
If the sad_count is 0, set the hw to stereo and change the error message to a warn. A lot of monitors don't set the speaker allocation block.
--- drivers/gpu/drm/radeon/dce3_1_afmt.c | 4 ++-- drivers/gpu/drm/radeon/dce6_afmt.c | 6 +++--- drivers/gpu/drm/radeon/evergreen_hdmi.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/radeon/dce3_1_afmt.c +2 -2
@@ -49,8 +49,8 @@ static void dce3_2_afmt_write_speaker_al sad_count =drm_edid_to_speaker_allocation (radeon_connector->edid, &sadb);if (sad_count <0 ) { -DRM_ERROR ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count); -return ; +DRM_DEBUG ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count); + sad_count =0 ; }/* program the speaker allocation */
drivers/gpu/drm/radeon/dce6_afmt.c +3 -3
@@ -176,9 +176,9 @@ void dce6_afmt_write_speaker_allocation( } sad_count =drm_edid_to_speaker_allocation (radeon_connector_edid (connector), &sadb); -if (sad_count <=0 ) { -DRM_ERROR ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count); -return ; +if (sad_count <0 ) { +DRM_DEBUG ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count); + sad_count =0 ; }/* program the speaker allocation */
drivers/gpu/drm/radeon/evergreen_hdmi.c +3 -3
@@ -118,9 +118,9 @@ static void dce4_afmt_write_speaker_allo } sad_count =drm_edid_to_speaker_allocation (radeon_connector_edid (connector), &sadb); -if (sad_count <=0 ) { -DRM_ERROR ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count); -return ; +if (sad_count <0 ) { +DRM_DEBUG ("Couldn't read Speaker Allocation Data Block: %d\n" , sad_count); + sad_count =0 ; }/* program the speaker allocation */
Greg Kroah-Hartman
maintainerPATCH 170/319 drm/radeon: use gart memory for DMA ring tests
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit adfed2b0587289013f8143c54913ddfd44ac1fd3 upstream.
Avoids HDP cache flush issues when using vram which can cause ring test failures on certain boards.
--- drivers/gpu/drm/radeon/cik_sdma.c | 21 ++++++++++++--------- drivers/gpu/drm/radeon/r600_dma.c | 21 ++++++++++++--------- drivers/gpu/drm/radeon/radeon.h | 2 ++ 3 files changed, 26 insertions(+), 18 deletions(-)
drivers/gpu/drm/radeon/cik_sdma.c +12 -9
@@ -610,16 +610,19 @@ int cik_sdma_ring_test(struct radeon_dev {unsigned i;int r; -void __iomem *ptr = (void *)rdev->vram_scratch.ptr; +unsigned index;u32 tmp; +u64 gpu_addr; -if (!ptr) { -DRM_ERROR ("invalid vram scratch pointer\n" ); -return -EINVAL ; - } +if (ring->idx ==R600_RING_TYPE_DMA_INDEX ) + index =R600_WB_DMA_RING_TEST_OFFSET ; +else + index =CAYMAN_WB_DMA1_RING_TEST_OFFSET ; + + gpu_addr = rdev->wb.gpu_addr + index; tmp =0xCAFEDEAD ; -writel (tmp, ptr); + rdev->wb.wb[index/4 ] =cpu_to_le32 (tmp); r =radeon_ring_lock (rdev, ring,5 );if (r) {
@@ -627,14 +630,14 @@ int cik_sdma_ring_test(struct radeon_devreturn r; }radeon_ring_write (ring,SDMA_PACKET (SDMA_OPCODE_WRITE ,SDMA_WRITE_SUB_OPCODE_LINEAR ,0 )); -radeon_ring_write (ring, rdev->vram_scratch.gpu_addr &0xfffffffc ); -radeon_ring_write (ring,upper_32_bits (rdev->vram_scratch.gpu_addr)); +radeon_ring_write (ring,lower_32_bits (gpu_addr)); +radeon_ring_write (ring,upper_32_bits (gpu_addr));radeon_ring_write (ring,1 );/* number of DWs to follow */ radeon_ring_write (ring,0xDEADBEEF );radeon_ring_unlock_commit (rdev, ring, false);for (i =0 ; i < rdev->usec_timeout; i++) { - tmp =readl (ptr); + tmp =le32_to_cpu (rdev->wb.wb[index/4 ]);if (tmp ==0xDEADBEEF )break ;DRM_UDELAY (1 );
drivers/gpu/drm/radeon/r600_dma.c +12 -9
@@ -232,16 +232,19 @@ int r600_dma_ring_test(struct radeon_dev {unsigned i;int r; -void __iomem *ptr = (void *)rdev->vram_scratch.ptr; +unsigned index;u32 tmp; +u64 gpu_addr; -if (!ptr) { -DRM_ERROR ("invalid vram scratch pointer\n" ); -return -EINVAL ; - } +if (ring->idx ==R600_RING_TYPE_DMA_INDEX ) + index =R600_WB_DMA_RING_TEST_OFFSET ; +else + index =CAYMAN_WB_DMA1_RING_TEST_OFFSET ; + + gpu_addr = rdev->wb.gpu_addr + index; tmp =0xCAFEDEAD ; -writel (tmp, ptr); + rdev->wb.wb[index/4 ] =cpu_to_le32 (tmp); r =radeon_ring_lock (rdev, ring,4 );if (r) {
@@ -249,13 +252,13 @@ int r600_dma_ring_test(struct radeon_devreturn r; }radeon_ring_write (ring,DMA_PACKET (DMA_PACKET_WRITE ,0 ,0 ,1 )); -radeon_ring_write (ring, rdev->vram_scratch.gpu_addr &0xfffffffc ); -radeon_ring_write (ring,upper_32_bits (rdev->vram_scratch.gpu_addr) &0xff ); +radeon_ring_write (ring,lower_32_bits (gpu_addr)); +radeon_ring_write (ring,upper_32_bits (gpu_addr) &0xff );radeon_ring_write (ring,0xDEADBEEF );radeon_ring_unlock_commit (rdev, ring, false);for (i =0 ; i < rdev->usec_timeout; i++) { - tmp =readl (ptr); + tmp =le32_to_cpu (rdev->wb.wb[index/4 ]);if (tmp ==0xDEADBEEF )break ;DRM_UDELAY (1 );
drivers/gpu/drm/radeon/radeon.h +2 -0
@@ -1120,6 +1120,8 @@ struct radeon_wb {#define R600_WB_EVENT_OFFSET 3072#define CIK_WB_CP1_WPTR_OFFSET 3328#define CIK_WB_CP2_WPTR_OFFSET 3584 +#define R600_WB_DMA_RING_TEST_OFFSET 3588 +#define CAYMAN_WB_DMA1_RING_TEST_OFFSET 3592/** * struct radeon_pm - power management datas
Greg Kroah-Hartman
maintainerPATCH 171/319 drm/radeon: fix vm page table block size calculation
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 8e66e134e20b936179ea1535dd4ed19ec4f99dba upstream.
The page offset is 12 bits. For example if we have an 8 GB VM, we'd need 33 bits. The number of bits needed for PD + PT is 21 (33 - 12 or log2(8) + 18), not 20 (log2(8) + 17).
Noticed by Alexey during code review.
--- drivers/gpu/drm/radeon/radeon_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_device.c +1 -1
@@ -1130,7 +1130,7 @@ static void radeon_check_arguments(strucif (radeon_vm_block_size ==-1 ) {/* Total bits covered by PD + PTs */ -unsigned bits =ilog2 (radeon_vm_size) +17 ; +unsigned bits =ilog2 (radeon_vm_size) +18 ;/* Make sure the PD is 4K in size up to 8GB address space. Above that split equal between PD and PTs */
Greg Kroah-Hartman
maintainerPATCH 172/319 cpufreq: expose scaling_cur_freq sysfs file for set_policy() drivers
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dirk Brandewie <[email protected]>
commit c034b02e213d271b98c45c4a7b54af8f69aaac1e upstream.
Currently the core does not expose scaling_cur_freq for set_policy() drivers this breaks some userspace monitoring tools.
Change the core to expose this file for all drivers and if the set_policy() driver supports the get() callback use it to retrieve the current frequency.
--- drivers/cpufreq/cpufreq.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/cpufreq/cpufreq.c +17 -6
@@ -512,7 +512,18 @@ show_one(cpuinfo_max_freq, cpuinfo.max_fshow_one (cpuinfo_transition_latency, cpuinfo.transition_latency);show_one (scaling_min_freq, min);show_one (scaling_max_freq, max); -show_one (scaling_cur_freq, cur); + +static ssize_t show_scaling_cur_freq ( +struct cpufreq_policy *policy,char *buf) +{ +ssize_t ret; + +if (cpufreq_driver && cpufreq_driver->setpolicy && cpufreq_driver->get) + ret =sprintf (buf,"%u\n" , cpufreq_driver->get (policy->cpu)); +else + ret =sprintf (buf,"%u\n" , policy->cur); +return ret; +}static int cpufreq_set_policy (struct cpufreq_policy *policy,struct cpufreq_policy *new_policy);
@@ -906,11 +917,11 @@ static int cpufreq_add_dev_interface(strif (ret) goto err_out_kobj_put; } -if (has_target ()) { - ret =sysfs_create_file (&policy->kobj, &scaling_cur_freq.attr); -if (ret) - goto err_out_kobj_put; - } + + ret =sysfs_create_file (&policy->kobj, &scaling_cur_freq.attr); +if (ret) + goto err_out_kobj_put; +if (cpufreq_driver->bios_limit) { ret =sysfs_create_file (&policy->kobj, &bios_limit.attr);if (ret)
Greg Kroah-Hartman
maintainerPATCH 173/319 cpufreq: intel_pstate: Reflect current no_turbo state correctly
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriele Mazzotta <[email protected]>
commit 4521e1a0ce173daa23dfef8312d09051e057ff8e upstream.
Some BIOSes modify the state of MSR_IA32_MISC_ENABLE_TURBO_DISABLE based on the current power source for the system battery AC vs battery. Reflect the correct current state and ability to modify the no_turbo sysfs file based on current state of MSR_IA32_MISC_ENABLE_TURBO_DISABLE.
--- drivers/cpufreq/intel_pstate.c | 48 ++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 12 deletions(-)
drivers/cpufreq/intel_pstate.c +36 -12
@@ -138,6 +138,7 @@ struct perf_limits {static struct perf_limits limits = { .no_turbo =0 , + .turbo_disabled =0 , .max_perf_pct =100 , .max_perf =int_tofp (1 ), .min_perf_pct =0 ,
@@ -218,6 +219,18 @@ static inline void intel_pstate_reset_al } } +static inline void update_turbo_state (void ) +{ +u64 misc_en; +struct cpudata *cpu; + + cpu = all_cpu_data[0 ]; +rdmsrl (MSR_IA32_MISC_ENABLE , misc_en); + limits.turbo_disabled = + (misc_en &MSR_IA32_MISC_ENABLE_TURBO_DISABLE || + cpu->pstate.max_pstate == cpu->pstate.turbo_pstate); +} +/************************** debugfs begin ************************/ static int pid_param_set (void *data,u64 val) {
@@ -274,6 +287,20 @@ static void __init intel_pstate_debug_exreturn sprintf (buf,"%u\n" , limits.object); \ } +static ssize_t show_no_turbo (struct kobject *kobj, +struct attribute *attr,char *buf) +{ +ssize_t ret; + +update_turbo_state (); +if (limits.turbo_disabled) + ret =sprintf (buf,"%u\n" , limits.turbo_disabled); +else + ret =sprintf (buf,"%u\n" , limits.no_turbo); + +return ret; +} +static ssize_t store_no_turbo (struct kobject *a,struct attribute *b,const char *buf,size_t count) {
@@ -283,11 +310,14 @@ static ssize_t store_no_turbo(struct kob ret =sscanf (buf,"%u" , &input);if (ret !=1 )return -EINVAL ; - limits.no_turbo =clamp_t (int, input,0 ,1 ); + +update_turbo_state ();if (limits.turbo_disabled) {pr_warn ("Turbo disabled by BIOS or unavailable on processor\n" ); - limits.no_turbo = limits.turbo_disabled; +return -EPERM ; } + limits.no_turbo =clamp_t (int, input,0 ,1 ); +return count; }
@@ -323,7 +353,6 @@ static ssize_t store_min_perf_pct(structreturn count; } -show_one (no_turbo, no_turbo);show_one (max_perf_pct, max_perf_pct);show_one (min_perf_pct, min_perf_pct);
@@ -501,7 +530,7 @@ static void intel_pstate_get_min_max(strint max_perf_adj;int min_perf; -if (limits.no_turbo) +if (limits.no_turbo || limits.turbo_disabled) max_perf = cpu->pstate.max_pstate; max_perf_adj =fp_toint (mul_fp (int_tofp (max_perf), limits.max_perf));
@@ -516,6 +545,8 @@ static void intel_pstate_set_pstate(stru {int max_perf, min_perf; +update_turbo_state (); +intel_pstate_get_min_max (cpu, &min_perf, &max_perf); pstate =clamp_t (int, pstate, min_perf, max_perf);
@@ -716,7 +747,7 @@ static int intel_pstate_set_policy(struc limits.min_perf =int_tofp (1 ); limits.max_perf_pct =100 ; limits.max_perf =int_tofp (1 ); - limits.no_turbo = limits.turbo_disabled; + limits.no_turbo =0 ;return 0 ; } limits.min_perf_pct = (policy->min *100 ) / policy->cpuinfo.max_freq;
@@ -759,7 +790,6 @@ static int intel_pstate_cpu_init(struct {struct cpudata *cpu;int rc; -u64 misc_en; rc =intel_pstate_init_cpu (policy->cpu);if (rc)
@@ -767,12 +797,6 @@ static int intel_pstate_cpu_init(struct cpu = all_cpu_data[policy->cpu]; -rdmsrl (MSR_IA32_MISC_ENABLE , misc_en); -if (misc_en &MSR_IA32_MISC_ENABLE_TURBO_DISABLE || - cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) { - limits.turbo_disabled =1 ; - limits.no_turbo =1 ; - }if (limits.min_perf_pct ==100 && limits.max_perf_pct ==100 ) policy->policy =CPUFREQ_POLICY_PERFORMANCE ;else
Greg Kroah-Hartman
maintainerPATCH 175/319 x86/platform/intel/iosf: Add Braswell PCI ID
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: "David E. Box" <[email protected]>
commit 849f5d894383d25c49132437aa289c9a9c98d5df upstream.
Add Braswell PCI ID to list of supported ID's for the IOSF driver.
--- arch/x86/kernel/iosf_mbi.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kernel/iosf_mbi.c +2 -0
@@ -26,6 +26,7 @@#include <asm/iosf_mbi.h> #define PCI_DEVICE_ID_BAYTRAIL 0x0F00 +#define PCI_DEVICE_ID_BRASWELL 0x2280#define PCI_DEVICE_ID_QUARK_X1000 0x0958static DEFINE_SPINLOCK (iosf_mbi_lock);
@@ -204,6 +205,7 @@ static int iosf_mbi_probe(struct pci_devstatic const struct pci_device_id iosf_mbi_pci_ids[] = { {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_BAYTRAIL ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_BRASWELL ) }, {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_QUARK_X1000 ) }, {0 , }, };
Greg Kroah-Hartman
maintainerPATCH 176/319 x86: Add cpu_detect_cache_sizes to init_intel() add Quark legacy_cache()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit aece118e487a744eafcdd0c77fe32b55ee2092a1 upstream.
Intel processors which don't report cache information via cpuid(2) or cpuid(4) need quirk code in the legacy_cache_size callback to report this data. For Intel that callback is is intel_size_cache().
This patch enables calling of cpu_detect_cache_sizes() inside of init_intel() and hence the calling of the legacy_cache callback in intel_size_cache(). Adding this call will ensure that PIII Tualatin currently in intel_size_cache() and Quark SoC X1000 being added to intel_size_cache() in this patch will report their respective cache sizes.
This model of calling cpu_detect_cache_sizes() is consistent with AMD/Via/Cirix/Transmeta and Centaur.
Also added is a string to idenitfy the Quark as Quark SoC X1000 giving better and more descriptive output via /proc/cpuinfo
Adding cpu_detect_cache_sizes to init_intel() will enable calling of intel_size_cache() on Intel processors which currently no code can reach. Therefore this patch will also re-enable reporting of PIII Tualatin cache size information as well as add Quark SoC X1000 support.
Comment text and cache flow logic suggested by Thomas Gleixner
--- arch/x86/kernel/cpu/intel.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/intel.c +16 -1
@@ -397,6 +397,13 @@ static void init_intel(struct cpuinfo_x8 } l2 =init_intel_cacheinfo (c); + +/* Detect legacy cache sizes if init_intel_cacheinfo did not */ +if (l2 ==0 ) { +cpu_detect_cache_sizes (c); + l2 = c->x86_cache_size; + } +if (c->cpuid_level >9 ) {unsigned eax =cpuid_eax (10 );/* Check for version and the number of counters */
@@ -500,6 +507,13 @@ static unsigned int intel_size_cache(str*/ if ((c->x86 ==6 ) && (c->x86_model ==11 ) && (size ==0 )) size =256 ; + +/* +* Intel Quark SoC X1000 contains a 4-way set associative +* 16K cache with a 16 byte cache line and 256 lines per tag +*/ +if ((c->x86 ==5 ) && (c->x86_model ==9 )) + size =16 ; return size; }#endif
@@ -701,7 +715,8 @@ static const struct cpu_dev intel_cpu_de [3] = "OverDrive PODP5V83", [4] = "Pentium MMX", [7] = "Mobile Pentium 75 - 200", - [8] = "Mobile Pentium MMX" + [8] = "Mobile Pentium MMX", + [9 ] ="Quark SoC X1000" , } }, { .family = 6, .model_names =
Greg Kroah-Hartman
maintainerPATCH 177/319 rtc: Disable EFI rtc for x86
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Fleming <[email protected]>
commit 7efe665903d0d963b0ebf4cab25cc3ae32c62600 upstream.
commit da167ad7638759 ("rtc: ia64: allow other architectures to use EFI RTC") inadvertently introduced a regression for x86 because we've been careful not to enable the EFI rtc driver due to the generally buggy implementations of the time-related EFI runtime services.
In fact, since the above commit was merged we've seen reports of crashes on 32-bit tablets,
https://bugzilla.kernel.org/show_bug.cgi?id=84241#c21
Disable it explicitly for x86 so that we don't give users false hope that this driver will work - it won't, and your machine is likely to crash.
--- drivers/rtc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/Kconfig +1 -1
@@ -806,7 +806,7 @@ config RTC_DRV_DA9063 config RTC_DRV_EFI tristate "EFI RTC" - depends on EFI + depends on EFI && !X86 help If you say yes here you will get support for the EFI Real Time Clock.
Greg Kroah-Hartman
maintainerPATCH 178/319 intel_pstate: Dont lose sysfs settings during cpu offline
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dirk Brandewie <[email protected]>
commit c034871712730a33e0267095f48b62eae958499c upstream.
The user may have custom settings don't destroy them during suspend.
--- drivers/cpufreq/intel_pstate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/cpufreq/intel_pstate.c +3 -3
@@ -702,7 +702,9 @@ static int intel_pstate_init_cpu(unsigne {struct cpudata *cpu; - all_cpu_data[cpunum] =kzalloc (sizeof (struct cpudata ),GFP_KERNEL ); +if (!all_cpu_data[cpunum]) + all_cpu_data[cpunum] =kzalloc (sizeof (struct cpudata ), +GFP_KERNEL );if (!all_cpu_data[cpunum])return -ENOMEM ;
@@ -783,8 +785,6 @@ static void intel_pstate_stop_cpu(structdel_timer_sync (&all_cpu_data[cpu_num]->timer);intel_pstate_set_pstate (cpu, cpu->pstate.min_pstate); -kfree (all_cpu_data[cpu_num]); - all_cpu_data[cpu_num] =NULL ; }static int intel_pstate_cpu_init (struct cpufreq_policy *policy)
Greg Kroah-Hartman
maintainerPATCH 179/319 intel_pstate: Fix BYT frequency reporting
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dirk Brandewie <[email protected]>
commit b27580b05e6f5253228debc60b8ff4a786ff573a upstream.
BYT has a different conversion from P state to frequency than the core processors. This causes the min/max and current frequency to be misreported on some BYT SKUs. Tested on BYT N2820, Ivybridge and Haswell processors.
--- drivers/cpufreq/intel_pstate.c | 42 +++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-)
drivers/cpufreq/intel_pstate.c +36 -6
@@ -64,6 +64,7 @@ struct pstate_data {int current_pstate;int min_pstate;int max_pstate; +int scaling;int turbo_pstate; };
@@ -113,6 +114,7 @@ struct pstate_funcs {int (*get_max)(void );int (*get_min)(void );int (*get_turbo)(void ); +int (*get_scaling)(void );void (*set)(struct cpudata *,int pstate);void (*get_vid)(struct cpudata *); };
@@ -433,6 +435,22 @@ static void byt_set_pstate(struct cpudatwrmsrl (MSR_IA32_PERF_CTL , val); } +#define BYT_BCLK_FREQS 5 +static int byt_freq_table[BYT_BCLK_FREQS ] = {833 ,1000 ,1333 ,1167 ,800 }; + +static int byt_get_scaling (void ) +{ +u64 value; +int i; + +rdmsrl (MSR_FSB_FREQ , value); + i = value &0x3 ; + +BUG_ON (i >BYT_BCLK_FREQS ); + +return byt_freq_table[i] *100 ; +} +static void byt_get_vid (struct cpudata *cpudata) {u64 value;
@@ -478,6 +496,11 @@ static int core_get_turbo_pstate(void)return ret; } +static inline int core_get_scaling (void ) +{ +return 100000 ; +} +static void core_set_pstate (struct cpudata *cpudata,int pstate) {u64 val;
@@ -502,6 +525,7 @@ static struct cpu_defaults core_params = .get_max = core_get_max_pstate, .get_min = core_get_min_pstate, .get_turbo = core_get_turbo_pstate, + .get_scaling = core_get_scaling, .set = core_set_pstate, }, };
@@ -520,6 +544,7 @@ static struct cpu_defaults byt_params = .get_min = byt_get_min_pstate, .get_turbo = byt_get_turbo_pstate, .set = byt_set_pstate, + .get_scaling = byt_get_scaling, .get_vid = byt_get_vid, }, };
@@ -554,7 +579,7 @@ static void intel_pstate_set_pstate(struif (pstate == cpu->pstate.current_pstate)return ; -trace_cpu_frequency (pstate *100000 , cpu->cpu); +trace_cpu_frequency (pstate * cpu->pstate.scaling, cpu->cpu); cpu->pstate.current_pstate = pstate;
@@ -566,6 +591,7 @@ static void intel_pstate_get_cpu_pstates cpu->pstate.min_pstate = pstate_funcs.get_min (); cpu->pstate.max_pstate = pstate_funcs.get_max (); cpu->pstate.turbo_pstate = pstate_funcs.get_turbo (); + cpu->pstate.scaling = pstate_funcs.get_scaling ();if (pstate_funcs.get_vid) pstate_funcs.get_vid (cpu);
@@ -581,7 +607,9 @@ static inline void intel_pstate_calc_bus core_pct =div64_u64 (core_pct,int_tofp (sample->mperf)); sample->freq =fp_toint ( -mul_fp (int_tofp (cpu->pstate.max_pstate *1000 ), core_pct)); +mul_fp (int_tofp ( + cpu->pstate.max_pstate * cpu->pstate.scaling /100 ), + core_pct)); sample->core_pct_busy = (int32_t )core_pct; }
@@ -803,12 +831,13 @@ static int intel_pstate_cpu_init(structelse policy->policy =CPUFREQ_POLICY_POWERSAVE ; - policy->min = cpu->pstate.min_pstate *100000 ; - policy->max = cpu->pstate.turbo_pstate *100000 ; + policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling; + policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling;/* cpuinfo and default policy values */ - policy->cpuinfo.min_freq = cpu->pstate.min_pstate *100000 ; - policy->cpuinfo.max_freq = cpu->pstate.turbo_pstate *100000 ; + policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; + policy->cpuinfo.max_freq = + cpu->pstate.turbo_pstate * cpu->pstate.scaling; policy->cpuinfo.transition_latency =CPUFREQ_ETERNAL ;cpumask_set_cpu (policy->cpu, policy->cpus);
@@ -866,6 +895,7 @@ static void copy_cpu_funcs(struct pstate pstate_funcs.get_max = funcs->get_max; pstate_funcs.get_min = funcs->get_min; pstate_funcs.get_turbo = funcs->get_turbo; + pstate_funcs.get_scaling = funcs->get_scaling; pstate_funcs.set = funcs->set; pstate_funcs.get_vid = funcs->get_vid; }
Greg Kroah-Hartman
maintainerPATCH 180/319 intel_pstate: Correct BYT VID values.
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dirk Brandewie <[email protected]>
commit d022a65ed2473fac4a600e3424503dc571160a3e upstream.
Using a VID value that is not high enough for the requested P state can cause machine checks. Add a ceiling function to ensure calulated VIDs with fractional values are set to the next highest integer VID value.
The algorythm for calculating the non-trubo VID from the BIOS writers guide is:
vid_ratio = (vid_max - vid_min) / (max_pstate - min_pstate) vid = ceiling(vid_min + (req_pstate - min_pstate) * vid_ratio)
--- drivers/cpufreq/intel_pstate.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/cpufreq/intel_pstate.c +12 -1
@@ -52,6 +52,17 @@ static inline int32_t div_fp(int32_t x,return div_s64 ((int64_t )x <<FRAC_BITS , y); } +static inline int ceiling_fp (int32_t x) +{ +int mask, ret; + + ret =fp_toint (x); + mask = (1 <<FRAC_BITS ) -1 ; +if (x & mask) + ret +=1 ; +return ret; +} +struct sample {int32_t core_pct_busy;u64 aperf;
@@ -425,7 +436,7 @@ static void byt_set_pstate(struct cpudat cpudata->vid.ratio); vid_fp =clamp_t (int32_t, vid_fp, cpudata->vid.min, cpudata->vid.max); - vid =fp_toint (vid_fp); + vid =ceiling_fp (vid_fp);if (pstate > cpudata->pstate.max_pstate) vid = cpudata->vid.turbo;
Greg Kroah-Hartman
maintainerPATCH 181/319 freezer: Do not freeze tasks killed by OOM killer
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Wang <[email protected]>
commit 51fae6da640edf9d266c94f36bc806c63c301991 upstream.
Since f660daac474c6f (oom: thaw threads if oom killed thread is frozen before deferring) OOM killer relies on being able to thaw a frozen task to handle OOM situation but a3201227f803 (freezer: make freezing() test freeze conditions in effect instead of TIF_FREEZE) has reorganized the code and stopped clearing freeze flag in __thaw_task. This means that the target task only wakes up and goes into the fridge again because the freezing condition hasn't changed for it. This reintroduces the bug fixed by f660daac474c6f.
Fix the issue by checking for TIF_MEMDIE thread flag in freezing_slow_path and exclude the task from freezing completely. If a task was already frozen it would get woken by __thaw_task from OOM killer and get out of freezer after rechecking freezing().
Changes since v1
- put TIF_MEMDIE check into freezing_slowpath rather than in __refrigerator as per Oleg
- return __thaw_task into oom_scan_process_thread because oom_kill_process will not wake task in the fridge because it is sleeping uninterruptible
--- kernel/freezer.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/freezer.c +3 -0
@@ -42,6 +42,9 @@ bool freezing_slow_path(struct task_struif (p->flags & (PF_NOFREEZE |PF_SUSPEND_TASK ))return false; +if (test_thread_flag (TIF_MEMDIE )) +return false; +if (pm_nosig_freezing ||cgroup_freezing (p))return true;
Greg Kroah-Hartman
maintainerPATCH 182/319 fix inode leaks on d_splice_alias() failure exits
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 51486b900ee92856b977eacfc5bfbe6565028070 upstream.
d_splice_alias() callers expect it to either stash the inode reference into a new alias, or drop the inode reference. That makes it possible to just return d_splice_alias() result from ->lookup() instance, without any extra housekeeping required.
Unfortunately, that should include the failure exits. If d_splice_alias() returns an error, it leaves the dentry it has been given negative and thus it *must* drop the inode reference. Easily fixed, but it goes way back and will need backporting.
--- fs/dcache.c | 2 ++ 1 file changed, 2 insertions(+)
fs/dcache.c +2 -0
@@ -2675,11 +2675,13 @@ struct dentry *d_splice_alias(struct inoif (!IS_ROOT (new)) {spin_unlock (&inode->i_lock);dput (new); +iput (inode);return ERR_PTR (-EIO ); }if (d_ancestor (new, dentry)) {spin_unlock (&inode->i_lock);dput (new); +iput (inode);return ERR_PTR (-EIO ); }write_seqlock (&rename_lock);
Greg Kroah-Hartman
maintainerPATCH 183/319 ACPI: invoke acpi_device_wakeup() with correct parameters
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Rui <[email protected]>
commit 67598a1d3140a66f57aa6bcb8d22c4c2b7e910f5 upstream.
Fix a bug that invokes acpi_device_wakeup() with wrong parameters.
--- drivers/acpi/device_pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/device_pm.c +1 -1
@@ -710,7 +710,7 @@ int acpi_pm_device_run_wake(struct devic return -ENODEV; } -return acpi_device_wakeup (adev, enable,ACPI_STATE_S0 ); +return acpi_device_wakeup (adev,ACPI_STATE_S0 , enable); }EXPORT_SYMBOL (acpi_pm_device_run_wake);#endif /* CONFIG_PM_RUNTIME */
Greg Kroah-Hartman
maintainerPATCH 184/319 x86: ACPI: Do not translate GSI number if IOAPIC is disabled
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiang Liu <[email protected]>
commit 961b6a7003acec4f9d70dabc1a253b783cb74272 upstream.
When IOAPIC is disabled, acpi_gsi_to_irq() should return gsi directly instead of calling mp_map_gsi_to_irq() to translate gsi to IRQ by IOAPIC. It fixes https://bugzilla.kernel.org/show_bug.cgi?id=84381.
This regression was introduced with commit 6b9fb7082409 "x86, ACPI,
irq: Consolidate algorithm of mapping (ioapic, pin) to IRQ number"
--- arch/x86/kernel/acpi/boot.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
arch/x86/kernel/acpi/boot.c +9 -5
@@ -604,14 +604,18 @@ void __init acpi_pic_sci_set_trigger(unsint acpi_gsi_to_irq (u32 gsi,unsigned int *irqp) { -int irq =mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC |IOAPIC_MAP_CHECK ); +int irq; -if (irq >=0 ) { +if (acpi_irq_model ==ACPI_IRQ_MODEL_PIC ) { + *irqp = gsi; + }else { + irq =mp_map_gsi_to_irq (gsi, +IOAPIC_MAP_ALLOC |IOAPIC_MAP_CHECK ); +if (irq <0 ) +return -1 ; *irqp = irq; -return 0 ; } - -return -1 ; +return 0 ; }EXPORT_SYMBOL_GPL (acpi_gsi_to_irq);
Greg Kroah-Hartman
maintainerPATCH 185/319 ACPI, irq, x86: Return IRQ instead of GSI in mp_register_gsi()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiang Liu <[email protected]>
commit b77e8f435337baa1cd15852fb9db3f6d26cd8eb7 upstream.
Function mp_register_gsi() returns blindly the GSI number for the ACPI SCI interrupt. That causes a regression when the GSI for ACPI SCI is shared with other devices.
The regression was caused by commit 84245af7297ced9e8fe "x86, irq, ACPI:
Change __acpi_register_gsi to return IRQ number instead of GSI" and exposed on a SuperMicro system, which shares one GSI between ACPI SCI and PCI device, with following failure:
http://sourceforge.net/p/linux1394/mailman/linux1394-user/?viewmonth=201410
[ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 20 low level) [ 2.699224] firewire_ohci 0000:06:00.0: failed to allocate interrupt
20
Return mp_map_gsi_to_irq(gsi, 0) instead of the GSI number.
--- arch/x86/kernel/acpi/boot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/acpi/boot.c +1 -1
@@ -397,7 +397,7 @@ static int mp_register_gsi(struct device/* Don't set up the ACPI SCI because it's already set up */ if (acpi_gbl_FADT.sci_interrupt == gsi) -return gsi; +return mp_map_gsi_to_irq (gsi,IOAPIC_MAP_ALLOC ); trigger = trigger ==ACPI_EDGE_SENSITIVE ?0 :1 ; polarity = polarity ==ACPI_ACTIVE_HIGH ?0 :1 ;
Greg Kroah-Hartman
maintainerPATCH 187/319 OOM, PM: OOM killed task shouldnt escape PM suspend
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Hocko <[email protected]>
commit 5695be142e203167e3cb515ef86a88424f3524eb upstream.
PM freezer relies on having all tasks frozen by the time devices are getting frozen so that no task will touch them while they are getting frozen. But OOM killer is allowed to kill an already frozen task in order to handle OOM situtation. In order to protect from late wake ups OOM killer is disabled after all tasks are frozen. This, however, still keeps a window open when a killed task didn't manage to die by the time freeze_processes finishes.
Reduce the race window by checking all tasks after OOM killer has been disabled. This is still not race free completely unfortunately because oom_killer_disable cannot stop an already ongoing OOM killer so a task might still wake up from the fridge and get killed without freeze_processes noticing. Full synchronization of OOM and freezer is, however, too heavy weight for this highly unlikely case.
Introduce and check oom_kills counter which gets incremented early when the allocator enters __alloc_pages_may_oom path and only check all the tasks if the counter changes during the freezing attempt. The counter is updated so early to reduce the race window since allocator checked oom_killer_disabled which is set by PM-freezing code. A false positive will push the PM-freezer into a slow path but that is not a big deal.
Changes since v1
- push the re-check loop out of freeze_processes into check_frozen_processes and invert the condition to make the code more readable as per Rafael
--- include/linux/oom.h | 3 +++ kernel/power/process.c | 40 +++++++++++++++++++++++++++++++++++++++- mm/oom_kill.c | 17 +++++++++++++++++ mm/page_alloc.c | 8 ++++++++ 4 files changed, 67 insertions(+), 1 deletion(-)
include/linux/oom.h +3 -0
@@ -50,6 +50,9 @@ static inline bool oom_task_origin(constextern unsigned long oom_badness (struct task_struct *p,struct mem_cgroup *memcg,const nodemask_t *nodemask,unsigned long totalpages); + +extern int oom_kills_count (void ); +extern void note_oom_kill (void ); extern void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, unsigned int points, unsigned long totalpages, struct mem_cgroup *memcg, nodemask_t *nodemask,
kernel/power/process.c +39 -1
@@ -108,6 +108,28 @@ static int try_to_freeze_tasks(bool userreturn todo ? -EBUSY :0 ; } +/* +* Returns true if all freezable tasks (except for current) are frozen already +*/ +static bool check_frozen_processes (void ) +{ +struct task_struct *g, *p; +bool ret = true; + +read_lock (&tasklist_lock); +for_each_process_thread (g, p) { +if (p != current && !freezer_should_skip (p) && + !frozen (p)) { + ret = false; + goto done; + } + } +done: +read_unlock (&tasklist_lock); + +return ret; +} +/** * freeze_processes - Signal user space processes to enter the refrigerator. * The current thread will not be frozen. The same process that calls
@@ -118,6 +140,7 @@ static int try_to_freeze_tasks(bool userint freeze_processes (void ) {int error; +int oom_kills_saved; error =__usermodehelper_disable (UMH_FREEZING );if (error)
@@ -131,12 +154,27 @@ int freeze_processes(void)printk ("Freezing user space processes ... " ); pm_freezing = true; + oom_kills_saved =oom_kills_count (); error =try_to_freeze_tasks (true);if (!error) { -printk ("done." );__usermodehelper_set_disable_depth (UMH_DISABLED );oom_killer_disable (); + +/* +* There might have been an OOM kill while we were +* freezing tasks and the killed task might be still +* on the way out so we have to double check for race. +*/ +if (oom_kills_count () != oom_kills_saved && + !check_frozen_processes ()) { +__usermodehelper_set_disable_depth (UMH_ENABLED ); +printk ("OOM in progress." ); + error = -EBUSY ; + goto done; + } +printk ("done." ); } +done:printk ("\n" );BUG_ON (in_atomic ());
mm/oom_kill.c +17 -0
@@ -404,6 +404,23 @@ static void dump_header(struct task_strudump_tasks (memcg, nodemask); } +/* +* Number of OOM killer invocations (including memcg OOM killer). +* Primarily used by PM freezer to check for potential races with +* OOM killed frozen task. +*/ +static atomic_t oom_kills =ATOMIC_INIT (0 ); + +int oom_kills_count (void ) +{ +return atomic_read (&oom_kills); +} + +void note_oom_kill (void ) +{ +atomic_inc (&oom_kills); +} +#define K (x) ((x) << (PAGE_SHIFT-10))/* * Must be called while holding a reference to p, which will be released upon
mm/page_alloc.c +8 -0
@@ -2253,6 +2253,14 @@ __alloc_pages_may_oom(gfp_t gfp_mask, un }/* +* PM-freezer should be notified that there might be an OOM killer on +* its way to kill and wake somebody up. This is too early and we might +* end up not killing anything but false positives are acceptable. +* See freeze_processes. +*/ +note_oom_kill (); + +/* * Go through the zonelist yet one more time, keep very high watermark * here, this is only to catch a parallel oom killing, we must fail if * we're still under heavy pressure.
Greg Kroah-Hartman
maintainerPATCH 188/319 iio: st_sensors: Fix buffer copy
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin van der Gracht <[email protected]>
commit 4250c90b30b8bf2a1a21122ba0484f8f351f152d upstream.
Use byte_for_channel as iterator to properly initialize the buffer.
--- drivers/iio/common/st_sensors/st_sensors_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/common/st_sensors/st_sensors_buffer.c +1 -1
@@ -71,7 +71,7 @@ int st_sensors_get_buffer_element(struct goto st_sensors_free_memory; } -for (i =0 ; i < n * num_data_channels; i++) { +for (i =0 ; i < n * byte_for_channel; i++) {if (i < n) buf[i] = rx_array[i];else
Greg Kroah-Hartman
maintainerPATCH 189/319 iio: adc: mxs-lradc: Disable the clock on probe failure
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
commit 75d7ed3b9e7cb79a3b0e1f417fb674d54b4fc668 upstream.
We should disable lradc->clk in the case of errors in the probe function.
--- drivers/staging/iio/adc/mxs-lradc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/staging/iio/adc/mxs-lradc.c +8 -4
@@ -1565,14 +1565,16 @@ static int mxs_lradc_probe(struct platfo/* Grab all IRQ sources */ for (i =0 ; i < of_cfg->irq_count; i++) { lradc->irq[i] =platform_get_irq (pdev, i); -if (lradc->irq[i] <0 ) -return lradc->irq[i]; +if (lradc->irq[i] <0 ) { + ret = lradc->irq[i]; + goto err_clk; + } ret =devm_request_irq (dev, lradc->irq[i], mxs_lradc_handle_irq,0 , of_cfg->irq_name[i], iio);if (ret) -return ret; + goto err_clk; } lradc->vref_mv = of_cfg->vref_mv;
@@ -1594,7 +1596,7 @@ static int mxs_lradc_probe(struct platfo &mxs_lradc_trigger_handler, &mxs_lradc_buffer_ops);if (ret) -return ret; + goto err_clk; ret =mxs_lradc_trigger_init (iio);if (ret)
@@ -1649,6 +1651,8 @@ err_dev:mxs_lradc_trigger_remove (iio); err_trig:iio_triggered_buffer_cleanup (iio); +err_clk: +clk_disable_unprepare (lradc->clk);return ret; }
Greg Kroah-Hartman
maintainerPATCH 190/319 staging:iio:ad5933: Fix NULL pointer deref when enabling buffer
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lars-Peter Clausen <[email protected]>
commit 824269c5868d2a7a26417e5ef3841a27d42c6139 upstream.
In older versions of the IIO framework it was possible to pass a completely different set of channels to iio_buffer_register() as the one that is assigned to the IIO device. Commit 959d2952d124 ("staging:iio: make iio_sw_buffer_preenable much more general.") introduced a restriction that requires that the set of channels that is passed to iio_buffer_register() is a subset of the channels assigned to the IIO device as the IIO core will use the list of channels that is assigned to the device to lookup a channel by scan index in iio_compute_scan_bytes(). If it can not find the channel the function will crash. This patch fixes the issue by making sure that the same set of channels is assigned to the IIO device and passed to iio_buffer_register().
Fixes the follow NULL pointer derefernce kernel crash:
Unable to handle kernel NULL pointer dereference at virtual address 00000016 pgd = d53d0000 [00000016] *pgd=1534e831, *pte=00000000, *ppte=00000000 Internal error: Oops: 17 [#1] PREEMPT SMP ARM Modules linked in: CPU: 1 PID: 1626 Comm: bash Not tainted 3.15.0-19969-g2a180eb-dirty #9545 task: d6c124c0 ti: d539a000 task.ti: d539a000 PC is at iio_compute_scan_bytes+0x34/0xa8 LR is at iio_compute_scan_bytes+0x34/0xa8 pc : [<c03052e4>] lr : [<c03052e4>] psr: 60070013 sp : d539beb8 ip : 00000001 fp : 00000000 r10: 00000002 r9 : 00000000 r8 : 00000001 r7 : 00000000 r6 : d6dc8800 r5 : d7571000 r4 : 00000002 r3 : d7571000 r2 : 00000044 r1 : 00000001 r0 : 00000000 Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user Control: 18c5387d Table: 153d004a DAC: 00000015 Process bash (pid: 1626, stack limit = 0xd539a240) Stack: (0xd539beb8 to 0xd539c000) bea0: c02fc0e4 d7571000 bec0: d76c1640 d6dc8800 d757117c 00000000 d757112c c0305b04 d76c1690 d76c1640 bee0: d7571188 00000002 00000000 d7571000 d539a000 00000000 000dd1c8 c0305d54 bf00: d7571010 0160b868 00000002 c69d3900 d7573278 d7573308 c69d3900 c01ece90 bf20: 00000002 c0103fac c0103f6c d539bf88 00000002 c69d3b00 c69d3b0c c0103468 bf40: 00000000 00000000 d7694a00 00000002 000af408 d539bf88 c000dd84 c00b2f94 bf60: d7694a00 000af408 00000002 d7694a00 d7694a00 00000002 000af408 c000dd84 bf80: 00000000 c00b32d0 00000000 00000000 00000002 b6f1aa78 00000002 000af408 bfa0: 00000004 c000dc00 b6f1aa78 00000002 00000001 000af408 00000002 00000000 bfc0: b6f1aa78 00000002 000af408 00000004 be806a4c 000a6094 00000000 000dd1c8 bfe0: 00000000 be8069cc b6e8ab77 b6ec125c 40070010 00000001 22940489 154a5007 [<c03052e4>] (iio_compute_scan_bytes) from [<c0305b04>] (__iio_update_buffers+0x248/0x438) [<c0305b04>] (__iio_update_buffers) from [<c0305d54>] (iio_buffer_store_enable+0x60/0x7c) [<c0305d54>] (iio_buffer_store_enable) from [<c01ece90>] (dev_attr_store+0x18/0x24) [<c01ece90>] (dev_attr_store) from [<c0103fac>] (sysfs_kf_write+0x40/0x4c) [<c0103fac>] (sysfs_kf_write) from [<c0103468>] (kernfs_fop_write+0x110/0x154) [<c0103468>] (kernfs_fop_write) from [<c00b2f94>] (vfs_write+0xd0/0x160) [<c00b2f94>] (vfs_write) from [<c00b32d0>] (SyS_write+0x40/0x78) [<c00b32d0>] (SyS_write) from [<c000dc00>] (ret_fast_syscall+0x0/0x30) Code: ea00000e e1a01008 e1a00005 ebfff6fc (e5d0a016)
--- drivers/staging/iio/impedance-analyzer/ad5933.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/staging/iio/impedance-analyzer/ad5933.c +4 -7
@@ -115,6 +115,7 @@ static const struct iio_chan_spec ad5933 .channel = 0, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), .address = AD5933_REG_TEMP_DATA, + .scan_index = -1, .scan_type = { .sign = 's', .realbits = 14,
@@ -125,8 +126,6 @@ static const struct iio_chan_spec ad5933 .indexed = 1, .channel = 0, .extend_name = "real_raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_SCALE), .address = AD5933_REG_REAL_DATA, .scan_index = 0, .scan_type = {
@@ -139,8 +138,6 @@ static const struct iio_chan_spec ad5933 .indexed = 1, .channel = 0, .extend_name = "imag_raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_SCALE), .address = AD5933_REG_IMAG_DATA, .scan_index = 1, .scan_type = {
@@ -748,14 +745,14 @@ static int ad5933_probe(struct i2c_clien indio_dev->name = id->name; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->channels = ad5933_channels; - indio_dev->num_channels =1 ;/* only register temp0_input */ + indio_dev->num_channels =ARRAY_SIZE (ad5933_channels); ret =ad5933_register_ring_funcs_and_init (indio_dev);if (ret) goto error_disable_reg; -/* skip temp0_input, register in0_(real|imag)_raw */ - ret =iio_buffer_register (indio_dev, &ad5933_channels[1 ],2 ); + ret =iio_buffer_register (indio_dev, ad5933_channels, +ARRAY_SIZE (ad5933_channels));if (ret) goto error_unreg_ring;
Greg Kroah-Hartman
maintainerPATCH 191/319 staging:iio:ad5933: Drop "raw" from channel names
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lars-Peter Clausen <[email protected]>
commit 6822ee34ad57b29a3b44df2c2829910f03c34fa4 upstream.
"raw" is the name of a channel property, but should not be part of the channel name itself.
--- drivers/staging/iio/impedance-analyzer/ad5933.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/impedance-analyzer/ad5933.c +2 -2
@@ -125,7 +125,7 @@ static const struct iio_chan_spec ad5933 .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .extend_name = "real_raw", + .extend_name = "real", .address = AD5933_REG_REAL_DATA, .scan_index = 0, .scan_type = {
@@ -137,7 +137,7 @@ static const struct iio_chan_spec ad5933 .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .extend_name = "imag_raw", + .extend_name = "imag", .address = AD5933_REG_IMAG_DATA, .scan_index = 1, .scan_type = {
Greg Kroah-Hartman
maintainerPATCH 192/319 iio: as3935: allocate correct iio_device size
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: George McCollister <[email protected]>
commit f73cde600d410ad4b31362a9c348016e40a146ea upstream.
--- drivers/iio/proximity/as3935.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/proximity/as3935.c +1 -1
@@ -330,7 +330,7 @@ static int as3935_probe(struct spi_devicreturn -EINVAL ; } - indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (st)); + indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*st));if (!indio_dev)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 193/319 staging:iio:ade7758: Fix NULL pointer deref when enabling buffer
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lars-Peter Clausen <[email protected]>
commit e10554738cab4224e097c2f9d975ea781a4fcde4 upstream.
In older versions of the IIO framework it was possible to pass a completely different set of channels to iio_buffer_register() as the one that is assigned to the IIO device. Commit 959d2952d124 ("staging:iio: make iio_sw_buffer_preenable much more general.") introduced a restriction that requires that the set of channels that is passed to iio_buffer_register() is a subset of the channels assigned to the IIO device as the IIO core will use the list of channels that is assigned to the device to lookup a channel by scan index in iio_compute_scan_bytes(). If it can not find the channel the function will crash. This patch fixes the issue by making sure that the same set of channels is assigned to the IIO device and passed to iio_buffer_register().
Note that we need to remove the IIO_CHAN_INFO_RAW and IIO_CHAN_INFO_SCALE info attributes from the channels since we don't actually want those to be registered.
Fixes the following crash:
Unable to handle kernel NULL pointer dereference at virtual address 00000016 pgd = d2094000 [00000016] *pgd=16e39831, *pte=00000000, *ppte=00000000 Internal error: Oops: 17 [#1] PREEMPT SMP ARM Modules linked in: CPU: 1 PID: 1695 Comm: bash Not tainted 3.17.0-06329-g29461ee #9686 task: d7768040 ti: d5bd4000 task.ti: d5bd4000 PC is at iio_compute_scan_bytes+0x38/0xc0 LR is at iio_compute_scan_bytes+0x34/0xc0 pc : [<c0316de8>] lr : [<c0316de4>] psr: 60070013 sp : d5bd5ec0 ip : 00000000 fp : 00000000 r10: d769f934 r9 : 00000000 r8 : 00000001 r7 : 00000000 r6 : c8fc6240 r5 : d769f800 r4 : 00000000 r3 : d769f800 r2 : 00000000 r1 : ffffffff r0 : 00000000 Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user Control: 18c5387d Table: 1209404a DAC: 00000015 Process bash (pid: 1695, stack limit = 0xd5bd4240) Stack: (0xd5bd5ec0 to 0xd5bd6000) 5ec0: d769f800 d7435640 c8fc6240 d769f984 00000000 c03175a4 d7435690 d7435640 5ee0: d769f990 00000002 00000000 d769f800 d5bd4000 00000000 000b43a8 c03177f4 5f00: d769f810 0162b8c8 00000002 c8fc7e00 d77f1d08 d77f1da8 c8fc7e00 c01faf1c 5f20: 00000002 c010694c c010690c d5bd5f88 00000002 c8fc6840 c8fc684c c0105e08 5f40: 00000000 00000000 d20d1580 00000002 000af408 d5bd5f88 c000de84 c00b76d4 5f60: d20d1580 000af408 00000002 d20d1580 d20d1580 00000002 000af408 c000de84 5f80: 00000000 c00b7a44 00000000 00000000 00000002 b6ebea78 00000002 000af408 5fa0: 00000004 c000dd00 b6ebea78 00000002 00000001 000af408 00000002 00000000 5fc0: b6ebea78 00000002 000af408 00000004 bee96a4c 000a6094 00000000 000b43a8 5fe0: 00000000 bee969cc b6e2eb77 b6e6525c 40070010 00000001 00000000 00000000 [<c0316de8>] (iio_compute_scan_bytes) from [<c03175a4>] (__iio_update_buffers+0x248/0x438) [<c03175a4>] (__iio_update_buffers) from [<c03177f4>] (iio_buffer_store_enable+0x60/0x7c) [<c03177f4>] (iio_buffer_store_enable) from [<c01faf1c>] (dev_attr_store+0x18/0x24) [<c01faf1c>] (dev_attr_store) from [<c010694c>] (sysfs_kf_write+0x40/0x4c) [<c010694c>] (sysfs_kf_write) from [<c0105e08>] (kernfs_fop_write+0x110/0x154) [<c0105e08>] (kernfs_fop_write) from [<c00b76d4>] (vfs_write+0xbc/0x170) [<c00b76d4>] (vfs_write) from [<c00b7a44>] (SyS_write+0x40/0x78) [<c00b7a44>] (SyS_write) from [<c000dd00>] (ret_fast_syscall+0x0/0x30)
--- drivers/staging/iio/meter/ade7758.h | 1 drivers/staging/iio/meter/ade7758_core.c | 33 +------------------------------ drivers/staging/iio/meter/ade7758_ring.c | 3 -- 3 files changed, 3 insertions(+), 34 deletions(-)
drivers/staging/iio/meter/ade7758.h +0 -1
@@ -119,7 +119,6 @@ struct ade7758_state {u8 *tx;u8 *rx;struct mutex buf_lock; -const struct iio_chan_spec *ade7758_ring_channels;struct spi_transfer ring_xfer[4 ];struct spi_message ring_msg;/*
drivers/staging/iio/meter/ade7758_core.c +2 -31
@@ -631,8 +631,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 0, .extend_name = "raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE), .scan_index = 0, .scan_type = {
@@ -645,8 +643,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 0, .extend_name = "raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT), .scan_index = 1, .scan_type = {
@@ -659,8 +655,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 0, .extend_name = "apparent_raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR), .scan_index = 2, .scan_type = {
@@ -673,8 +667,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 0, .extend_name = "active_raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR), .scan_index = 3, .scan_type = {
@@ -687,8 +679,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 0, .extend_name = "reactive_raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR), .scan_index = 4, .scan_type = {
@@ -701,8 +691,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 1, .extend_name = "raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE), .scan_index = 5, .scan_type = {
@@ -715,8 +703,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 1, .extend_name = "raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT), .scan_index = 6, .scan_type = {
@@ -729,8 +715,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 1, .extend_name = "apparent_raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR), .scan_index = 7, .scan_type = {
@@ -743,8 +727,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 1, .extend_name = "active_raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR), .scan_index = 8, .scan_type = {
@@ -757,8 +739,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 1, .extend_name = "reactive_raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR), .scan_index = 9, .scan_type = {
@@ -771,8 +751,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 2, .extend_name = "raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE), .scan_index = 10, .scan_type = {
@@ -785,8 +763,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 2, .extend_name = "raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT), .scan_index = 11, .scan_type = {
@@ -799,8 +775,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 2, .extend_name = "apparent_raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR), .scan_index = 12, .scan_type = {
@@ -813,8 +787,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 2, .extend_name = "active_raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR), .scan_index = 13, .scan_type = {
@@ -827,8 +799,6 @@ static const struct iio_chan_spec ade775 .indexed = 1, .channel = 2, .extend_name = "reactive_raw", - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .address = AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR), .scan_index = 14, .scan_type = {
@@ -869,13 +839,14 @@ static int ade7758_probe(struct spi_devi goto error_free_rx; } st->us = spi; - st->ade7758_ring_channels = &ade7758_channels[0 ];mutex_init (&st->buf_lock); indio_dev->name = spi->dev.driver->name; indio_dev->dev.parent = &spi->dev; indio_dev->info = &ade7758_info; indio_dev->modes =INDIO_DIRECT_MODE ; + indio_dev->channels = ade7758_channels; + indio_dev->num_channels =ARRAY_SIZE (ade7758_channels); ret =ade7758_configure_ring (indio_dev);if (ret)
drivers/staging/iio/meter/ade7758_ring.c +1 -2
@@ -85,7 +85,6 @@ static irqreturn_t ade7758_trigger_handl**/ static int ade7758_ring_preenable (struct iio_dev *indio_dev) { -struct ade7758_state *st =iio_priv (indio_dev);unsigned channel;if (!bitmap_empty (indio_dev->active_scan_mask, indio_dev->masklength))
@@ -95,7 +94,7 @@ static int ade7758_ring_preenable(struct indio_dev->masklength);ade7758_write_waveform_type (&indio_dev->dev, - st->ade7758_ring_channels[channel].address); + indio_dev->channels[channel].address);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 194/319 staging:iio:ade7758: Fix check if channels are enabled in prenable
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lars-Peter Clausen <[email protected]>
commit 79fa64eb2ee8ccb4bcad7f54caa2699730b10b22 upstream.
We should check if a channel is enabled, not if no channels are enabled.
--- drivers/staging/iio/meter/ade7758_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/meter/ade7758_ring.c +1 -1
@@ -87,7 +87,7 @@ static int ade7758_ring_preenable(struct {unsigned channel; -if (!bitmap_empty (indio_dev->active_scan_mask, indio_dev->masklength)) +if (bitmap_empty (indio_dev->active_scan_mask, indio_dev->masklength))return -EINVAL ; channel = find_first_bit(indio_dev->active_scan_mask,
Greg Kroah-Hartman
maintainerPATCH 195/319 staging:iio:ade7758: Remove "raw" from channel name
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lars-Peter Clausen <[email protected]>
commit b598aacc29331e7e638cd509108600e916c6331b upstream.
"raw" is a property of a channel, but should not be part of the name of channel.
--- drivers/staging/iio/meter/ade7758_core.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/staging/iio/meter/ade7758_core.c +9 -15
@@ -630,7 +630,6 @@ static const struct iio_chan_spec ade775 .type = IIO_VOLTAGE, .indexed = 1, .channel = 0, - .extend_name = "raw", .address = AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE), .scan_index = 0, .scan_type = {
@@ -642,7 +641,6 @@ static const struct iio_chan_spec ade775 .type = IIO_CURRENT, .indexed = 1, .channel = 0, - .extend_name = "raw", .address = AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT), .scan_index = 1, .scan_type = {
@@ -654,7 +652,7 @@ static const struct iio_chan_spec ade775 .type = IIO_POWER, .indexed = 1, .channel = 0, - .extend_name = "apparent_raw", + .extend_name = "apparent", .address = AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR), .scan_index = 2, .scan_type = {
@@ -666,7 +664,7 @@ static const struct iio_chan_spec ade775 .type = IIO_POWER, .indexed = 1, .channel = 0, - .extend_name = "active_raw", + .extend_name = "active", .address = AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR), .scan_index = 3, .scan_type = {
@@ -678,7 +676,7 @@ static const struct iio_chan_spec ade775 .type = IIO_POWER, .indexed = 1, .channel = 0, - .extend_name = "reactive_raw", + .extend_name = "reactive", .address = AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR), .scan_index = 4, .scan_type = {
@@ -690,7 +688,6 @@ static const struct iio_chan_spec ade775 .type = IIO_VOLTAGE, .indexed = 1, .channel = 1, - .extend_name = "raw", .address = AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE), .scan_index = 5, .scan_type = {
@@ -702,7 +699,6 @@ static const struct iio_chan_spec ade775 .type = IIO_CURRENT, .indexed = 1, .channel = 1, - .extend_name = "raw", .address = AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT), .scan_index = 6, .scan_type = {
@@ -714,7 +710,7 @@ static const struct iio_chan_spec ade775 .type = IIO_POWER, .indexed = 1, .channel = 1, - .extend_name = "apparent_raw", + .extend_name = "apparent", .address = AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR), .scan_index = 7, .scan_type = {
@@ -726,7 +722,7 @@ static const struct iio_chan_spec ade775 .type = IIO_POWER, .indexed = 1, .channel = 1, - .extend_name = "active_raw", + .extend_name = "active", .address = AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR), .scan_index = 8, .scan_type = {
@@ -738,7 +734,7 @@ static const struct iio_chan_spec ade775 .type = IIO_POWER, .indexed = 1, .channel = 1, - .extend_name = "reactive_raw", + .extend_name = "reactive", .address = AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR), .scan_index = 9, .scan_type = {
@@ -750,7 +746,6 @@ static const struct iio_chan_spec ade775 .type = IIO_VOLTAGE, .indexed = 1, .channel = 2, - .extend_name = "raw", .address = AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE), .scan_index = 10, .scan_type = {
@@ -762,7 +757,6 @@ static const struct iio_chan_spec ade775 .type = IIO_CURRENT, .indexed = 1, .channel = 2, - .extend_name = "raw", .address = AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT), .scan_index = 11, .scan_type = {
@@ -774,7 +768,7 @@ static const struct iio_chan_spec ade775 .type = IIO_POWER, .indexed = 1, .channel = 2, - .extend_name = "apparent_raw", + .extend_name = "apparent", .address = AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR), .scan_index = 12, .scan_type = {
@@ -786,7 +780,7 @@ static const struct iio_chan_spec ade775 .type = IIO_POWER, .indexed = 1, .channel = 2, - .extend_name = "active_raw", + .extend_name = "active", .address = AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR), .scan_index = 13, .scan_type = {
@@ -798,7 +792,7 @@ static const struct iio_chan_spec ade775 .type = IIO_POWER, .indexed = 1, .channel = 2, - .extend_name = "reactive_raw", + .extend_name = "reactive", .address = AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR), .scan_index = 14, .scan_type = {
Greg Kroah-Hartman
maintainerPATCH 196/319 serial: msm_serial: Fix kgdb continue
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Boyd <[email protected]>
commit 8b374399468da1c25db5b5d436b167aafc10fbdc upstream.
Frank reports that after continuing in kgdb the RX stale event doesn't occur until after the RX fifo is filled up with exactly the amount of characters programmed for the RX watermark (in this case it's 48). To read a single character from the uartdm hardware we force a stale event so that any characters in the RX packing buffer are flushed into the RX fifo immediately instead of waiting for a stale timeout or for the fifo to fill. Forcing that stale event asserts the stale interrupt but we never clear that interrupt via UART_CR_CMD_RESET_STALE_INT in the polling functions. So when kgdb continues the stale interrupt is left pending in the hardware and we don't timeout with a stale event, like we usually would if a user typed one character on the console, until the reset stale interrupt and stale event commands are sent. Frank could get things working again by running handle_rx_dm(). By putting enough characters into the fifo he could trigger a watermark interrupt, and thus cause handle_rx_dm() to run finally resetting the stale interrupt and enabling the stale event so that single characters would cause timeouts again.
The fix is to just do what the interrupt routine was doing all along and clear the stale interrupt and enable the event again. Doing this also smooths over any differences in the fifo behavior between v1.3 and v1.4 hardware allowing us to skip forcing the uart into single character mode.
--- drivers/tty/serial/msm_serial.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/tty/serial/msm_serial.c +7 -15
@@ -683,17 +683,6 @@ static void msm_power(struct uart_port * }#ifdef CONFIG_CONSOLE_POLL -static int msm_poll_init (struct uart_port *port) -{ -struct msm_port *msm_port =UART_TO_MSM (port); - -/* Enable single character mode on RX FIFO */ -if (msm_port->is_uartdm >=UARTDM_1P4 ) -msm_write (port,UARTDM_DMEN_RX_SC_ENABLE ,UARTDM_DMEN ); - -return 0 ; -} -static int msm_poll_get_char_single (struct uart_port *port) {struct msm_port *msm_port =UART_TO_MSM (port);
@@ -705,7 +694,7 @@ static int msm_poll_get_char_single(strureturn msm_read (port, rf_reg) &0xff ; } -static int msm_poll_get_char_dm_1p3 (struct uart_port *port) +static int msm_poll_get_char_dm (struct uart_port *port) {int c;static u32 slop;
@@ -729,6 +718,10 @@ static int msm_poll_get_char_dm_1p3(stru slop =msm_read (port,UARTDM_RF ); c = sp[0 ]; count--; +msm_write (port,UART_CR_CMD_RESET_STALE_INT ,UART_CR ); +msm_write (port,0xFFFFFF ,UARTDM_DMRX ); +msm_write (port,UART_CR_CMD_STALE_EVENT_ENABLE , +UART_CR ); }else { c =NO_POLL_CHAR ; }
@@ -752,8 +745,8 @@ static int msm_poll_get_char(struct uart imr =msm_read (port,UART_IMR );msm_write (port,0 ,UART_IMR ); -if (msm_port->is_uartdm ==UARTDM_1P3 ) - c =msm_poll_get_char_dm_1p3 (port); +if (msm_port->is_uartdm) + c =msm_poll_get_char_dm (port);else c =msm_poll_get_char_single (port);
@@ -812,7 +805,6 @@ static struct uart_ops msm_uart_pops = { .verify_port = msm_verify_port, .pm = msm_power, #ifdef CONFIG_CONSOLE_POLL - .poll_init = msm_poll_init, .poll_get_char = msm_poll_get_char, .poll_put_char = msm_poll_put_char, #endif
Greg Kroah-Hartman
maintainerPATCH 198/319 USB: serial: cp210x: add Silicon Labs 358x VID and PID
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathaniel Ting <[email protected]>
commit 35cc83eab097e5720a9cc0ec12bdc3a726f58381 upstream.
Enable Silicon Labs Ember VID chips to enumerate with the cp210x usb serial driver. EM358x devices operating with the Ember Z-Net 5.1.2 stack may now connect to host PCs over a USB serial link.
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -155,6 +155,7 @@ static const struct usb_device_id id_tab { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */ { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */ + { USB_DEVICE(0x1BA4, 0x0002) }, /* Silicon Labs 358x factory default */ { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ { USB_DEVICE(0x1D6F, 0x0010) }, /* Seluxit ApS RF Dongle */ { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */
Greg Kroah-Hartman
maintainerPATCH 199/319 usb: serial: ftdi_sio: add Awinda Station and Dongle products
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frans Klaver <[email protected]>
commit edd74ffab1f6909eee400c7de8ce621870aacac9 upstream.
Add new IDs for the Xsens Awinda Station and Awinda Dongle.
While at it, order the definitions by PID and add a logical separation between devices using Xsens' VID and those using FTDI's VID.
--- drivers/usb/serial/ftdi_sio.c | 2 ++ drivers/usb/serial/ftdi_sio_ids.h | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/usb/serial/ftdi_sio.c +2 -0
@@ -661,6 +661,8 @@ static const struct usb_device_id id_tab { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) }, { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) }, { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) }, + { USB_DEVICE(XSENS_VID, XSENS_AWINDA_DONGLE_PID) }, + { USB_DEVICE(XSENS_VID, XSENS_AWINDA_STATION_PID) }, { USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) }, { USB_DEVICE(XSENS_VID, XSENS_MTW_PID) }, { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) },
drivers/usb/serial/ftdi_sio_ids.h +5 -1
@@ -143,8 +143,12 @@* Xsens Technologies BV products (http://www.xsens.com). */ #define XSENS_VID 0x2639 -#define XSENS_CONVERTER_PID 0xD00D/* Xsens USB-serial converter */ +#define XSENS_AWINDA_STATION_PID 0x0101 +#define XSENS_AWINDA_DONGLE_PID 0x0102#define XSENS_MTW_PID 0x0200/* Xsens MTw */ +#define XSENS_CONVERTER_PID 0xD00D/* Xsens USB-serial converter */ + +/* Xsens devices using FTDI VID */ #define XSENS_CONVERTER_0_PID 0xD388/* Xsens USB converter */ #define XSENS_CONVERTER_1_PID 0xD389/* Xsens Wireless Receiver */ #define XSENS_CONVERTER_2_PID 0xD38A
Greg Kroah-Hartman
maintainerPATCH 200/319 usb: serial: ftdi_sio: add "bricked" FTDI device PID
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Perry Hung <[email protected]>
commit 7f2719f0003da1ad13124ef00f48d7514c79e30d upstream.
An official recent Windows driver from FTDI detects counterfeit devices and reprograms the internal EEPROM containing the USB PID to 0, effectively bricking the device.
Add support for this VID/PID pair to correctly bind the driver on these devices.
See:
http://hackaday.com/2014/10/22/watch-that-windows-update-ftdi-drivers-are-killing-fake-chips/
--- drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/ftdi_sio_ids.h | 6 ++++++ 2 files changed, 7 insertions(+)
drivers/usb/serial/ftdi_sio.c +1 -0
@@ -140,6 +140,7 @@ static struct ftdi_sio_quirk ftdi_8u2232* /sys/bus/usb-serial/drivers/ftdi_sio/new_id and send a patch or report. */ static const struct usb_device_id id_table_combined[] = { + {USB_DEVICE (FTDI_VID ,FTDI_BRICK_PID ) }, {USB_DEVICE (FTDI_VID ,FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID ) }, {USB_DEVICE (FTDI_VID ,FTDI_CTI_MINI_PID ) }, {USB_DEVICE (FTDI_VID ,FTDI_CTI_NANO_PID ) },
drivers/usb/serial/ftdi_sio_ids.h +6 -0
@@ -30,6 +30,12 @@/*** third-party PIDs (using FTDI_VID) ***/ +/* +* Certain versions of the official Windows FTDI driver reprogrammed +* counterfeit FTDI devices to PID 0. Support these devices anyway. +*/ +#define FTDI_BRICK_PID 0x0000 +#define FTDI_LUMEL_PD12_PID 0x6002/*
Greg Kroah-Hartman
maintainerPATCH 201/319 USB: cdc-acm: add device id for GW Instek AFG-2225
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit cf84a691a61606a2e7269907d3727e2d9fa148ee upstream.
Add device-id entry for GW Instek AFG-2225, which has a byte swapped bInterfaceSubClass (0x20).
--- drivers/usb/class/cdc-acm.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/class/cdc-acm.c +1 -0
@@ -1681,6 +1681,7 @@ static const struct usb_device_id acm_id { USB_DEVICE(0x0572, 0x1328), /* Shiro / Aztech USB MODEM UM-3100 */ .driver_info =NO_UNION_NORMAL ,/* has no union descriptor */ }, + { USB_DEVICE(0x2184, 0x001c) }, /* GW Instek AFG-2225 */ { USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */ },/* Motorola H24 HSPA module: */
Greg Kroah-Hartman
maintainerPATCH 202/319 USB: cdc-acm: only raise DTR on transitions from B0
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 4473d054ceb572557954f9536731d39b20937b0c upstream.
Make sure to only raise DTR on transitions from B0 in set_termios.
Also allow set_termios to be called from open with a termios_old of NULL. Note that DTR will not be raised prematurely in this case.
--- drivers/usb/class/cdc-acm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/class/cdc-acm.c +3 -2
@@ -980,11 +980,12 @@ static void acm_tty_set_termios(struct t/* FIXME: Needs to clear unsupported bits in the termios */ acm->clocal = ((termios->c_cflag &CLOCAL ) !=0 ); -if (!newline.dwDTERate) { +if (C_BAUD (tty) ==B0 ) { newline.dwDTERate = acm->line.dwDTERate; newctrl &= ~ACM_CTRL_DTR ; - }else + }else if (termios_old && (termios_old->c_cflag &CBAUD ) ==B0 ) { newctrl |=ACM_CTRL_DTR ; + }if (newctrl != acm->ctrlout)acm_set_control (acm, acm->ctrlout = newctrl);
Greg Kroah-Hartman
maintainerPATCH 203/319 USB: cdc-acm: add quirk for control-line state requests
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 2a8cdfde9237c4e1bd7c2e68c415b006491d23cc upstream.
Add new quirk for devices that cannot handle control-line state requests.
Note that we currently send these requests to all devices, regardless of whether they claim to support it, but that errors are only logged if support is claimed.
Since commit 0943d8ead30e ("USB: cdc-acm: use tty-port dtr_rts"), which only changed the timings for these requests slightly, this has been reported to cause occasional firmware crashes on Simtec Electronics Entropy Key devices after re-enumeration. Enable the quirk for this device.
--- drivers/usb/class/cdc-acm.c | 14 ++++++++++++-- drivers/usb/class/cdc-acm.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-)
drivers/usb/class/cdc-acm.c +12 -2
@@ -145,8 +145,15 @@ static int acm_ctrl_msg(struct acm *acm,/* devices aren't required to support these requests. * the cdc acm descriptor tells whether they do... */ -#define acm_set_control (acm, control) \ - acm_ctrl_msg(acm, USB_CDC_REQ_SET_CONTROL_LINE_STATE, control, NULL, 0) +static inline int acm_set_control (struct acm *acm,int control) +{ +if (acm->quirks &QUIRK_CONTROL_LINE_STATE ) +return -EOPNOTSUPP ; + +return acm_ctrl_msg (acm,USB_CDC_REQ_SET_CONTROL_LINE_STATE , + control,NULL ,0 ); +} +#define acm_set_line (acm, line) \ acm_ctrl_msg(acm, USB_CDC_REQ_SET_LINE_CODING, 0, line, sizeof *(line))#define acm_send_break (acm, ms) \
@@ -1315,6 +1322,7 @@ made_compressed_probe:tty_port_init (&acm->port); acm->port.ops = &acm_port_ops;init_usb_anchor (&acm->delayed); + acm->quirks = quirks; buf =usb_alloc_coherent (usb_dev, ctrlsize,GFP_KERNEL , &acm->ctrl_dma);if (!buf) {
@@ -1682,6 +1690,8 @@ static const struct usb_device_id acm_id { USB_DEVICE(0x0572, 0x1328), /* Shiro / Aztech USB MODEM UM-3100 */ .driver_info =NO_UNION_NORMAL ,/* has no union descriptor */ }, + { USB_DEVICE(0x20df, 0x0001), /* Simtec Electronics Entropy Key */ + .driver_info = QUIRK_CONTROL_LINE_STATE, }, { USB_DEVICE(0x2184, 0x001c) }, /* GW Instek AFG-2225 */ { USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */ },
drivers/usb/class/cdc-acm.h +2 -0
@@ -121,6 +121,7 @@ struct acm { unsigned int throttle_req:1; /* throttle requested */u8 bInterval;struct usb_anchor delayed;/* writes queued for a device about to be woken */ +unsigned long quirks; };#define CDC_DATA_INTERFACE_TYPE 0x0a
@@ -132,3 +133,4 @@ struct acm {#define NOT_A_MODEM BIT(3)#define NO_DATA_INTERFACE BIT(4)#define IGNORE_DEVICE BIT(5) +#define QUIRK_CONTROL_LINE_STATE BIT(6)
Greg Kroah-Hartman
maintainerPATCH 204/319 phy: omap-usb2: Enable runtime PM of omap-usb2 phy properly
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oussama Ghorbel <[email protected]>
commit f20531a9aae0c7378d9fa75b4b5d99b7eecab066 upstream.
The USB OTG port does not work since v3.16 on omap platform. This is a regression introduced by the commiteb82a3d846fa (phy: omap-usb2: Balance pm_runtime_enable() on probe failure
and remove).
This because the call to pm_runtime_enable() function is moved after the call to devm_phy_create() function, which has side effect since later in the subsequent calls of devm_phy_create() there is a check with pm_runtime_enabled() to configure few things.
--- drivers/phy/phy-omap-usb2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/phy/phy-omap-usb2.c +4 -2
@@ -262,14 +262,16 @@ static int omap_usb2_probe(struct platfo otg->phy = &phy->phy;platform_set_drvdata (pdev, phy); +pm_runtime_enable (phy->dev); generic_phy =devm_phy_create (phy->dev,NULL , &ops,NULL ); -if (IS_ERR (generic_phy)) +if (IS_ERR (generic_phy)) { +pm_runtime_disable (phy->dev);return PTR_ERR (generic_phy); + }phy_set_drvdata (generic_phy, phy); -pm_runtime_enable (phy->dev); phy_provider =devm_of_phy_provider_register (phy->dev, of_phy_simple_xlate);if (IS_ERR (phy_provider)) {
Greg Kroah-Hartman
maintainerPATCH 205/319 usb: option: add support for Telit LE910
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniele Palmas <[email protected]>
commit 2d0eb862dd477c3c4f32b201254ca0b40e6f465c upstream.
Add VID/PID for Telit LE910 modem. Interfaces description is almost the same than LE920, except that the qmi interface is number 2 (instead than 5).
--- drivers/usb/serial/option.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/serial/option.c +8 -0
@@ -269,6 +269,7 @@ static void option_instat_callback(struc#define TELIT_PRODUCT_DE910_DUAL 0x1010#define TELIT_PRODUCT_UE910_V2 0x1012#define TELIT_PRODUCT_LE920 0x1200 +#define TELIT_PRODUCT_LE910 0x1201/* ZTE PRODUCTS */ #define ZTE_VENDOR_ID 0x19d2
@@ -588,6 +589,11 @@ static const struct option_blacklist_inf .reserved = BIT(3) | BIT(4), }; +static const struct option_blacklist_info telit_le910_blacklist = { + .sendsetup =BIT (0 ), + .reserved =BIT (1 ) |BIT (2 ), +}; +static const struct option_blacklist_info telit_le920_blacklist = { .sendsetup =BIT (0 ), .reserved =BIT (1 ) |BIT (5 ),
@@ -1137,6 +1143,8 @@ static const struct usb_device_id option { 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_LE910), + .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920), .driver_info = (kernel_ulong_t)&telit_le920_blacklist }, { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
Greg Kroah-Hartman
maintainerPATCH 206/319 USB: option: add Haier CE81B CDMA modem
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
commit 012eee1522318b5ccd64d277d50ac32f7e9974fe upstream.
Port layout:
0: QCDM/DIAG
1: NMEA
2: AT
3: AT/PPP
--- drivers/usb/serial/option.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/option.c +2 -0
@@ -362,6 +362,7 @@ static void option_instat_callback(struc/* Haier products */ #define HAIER_VENDOR_ID 0x201e +#define HAIER_PRODUCT_CE81B 0x10f8#define HAIER_PRODUCT_CE100 0x2009/* Cinterion (formerly Siemens) products */
@@ -1620,6 +1621,7 @@ static const struct usb_device_id option { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) }, { USB_DEVICE(LONGCHEER_VENDOR_ID, IBALL_3_5G_CONNECT) }, { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, + { USB_DEVICE_AND_INTERFACE_INFO(HAIER_VENDOR_ID, HAIER_PRODUCT_CE81B, 0xff, 0xff, 0xff) },/* Pirelli */ { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) }, { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2, 0xff) },
Greg Kroah-Hartman
maintainerPATCH 208/319 wireless: rt2x00: add new rt2800usb device
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cyril Brulebois <[email protected]>
commit 664d6a792785cc677c2091038ce10322c8d04ae1 upstream.
0x1b75 0xa200 AirLive WN-200USB wireless 11b/g/n dongle
References: https://bugs.debian.org/766802
--- drivers/net/wireless/rt2x00/rt2800usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/rt2x00/rt2800usb.c +1 -0
@@ -1111,6 +1111,7 @@ static struct usb_device_id rt2800usb_de/* Ovislink */ { USB_DEVICE(0x1b75, 0x3071) }, { USB_DEVICE(0x1b75, 0x3072) }, + { USB_DEVICE(0x1b75, 0xa200) },/* Para */ { USB_DEVICE(0x20b8, 0x8888) },/* Pegatron */
Greg Kroah-Hartman
maintainerPATCH 209/319 Revert "usb: dwc3: dwc3-omap: Disable/Enable only wrapper interrupts in prepare/complete"
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roger Quadros <[email protected]>
commit b01ff5cb2fc99d45e4edc97077b6e17186570a16 upstream.
This reverts commit 02dae36aa649a66c5c6181157ddd806e7b4913fc.
That commit is bogus in two ways:
1) There's no way dwc3-omap's ->suspend() can cause any effect
on xhci's ->suspend(). Linux device driver model guarantees that a parent's ->suspend() will only be called after all children are suspended. dwc3-omap is the parent of the parent of xhci.
2) When implementing Deep Sleep states where context is lost, USBOTGSS_IRQ0 register, well, looses context so we _must_ rewrite it otherwise core IRQs will never be reenabled and USB will appear to be dead.
wrapper interrupts in prepare/complete)
--- drivers/usb/dwc3/dwc3-omap.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/usb/dwc3/dwc3-omap.c +2 -13
@@ -599,7 +599,7 @@ static int dwc3_omap_prepare(struct devi {struct dwc3_omap *omap =dev_get_drvdata (dev); -dwc3_omap_write_irqmisc_set (omap,0x00 ); +dwc3_omap_disable_irqs (omap);return 0 ; }
@@ -607,19 +607,8 @@ static int dwc3_omap_prepare(struct devistatic void dwc3_omap_complete (struct device *dev) {struct dwc3_omap *omap =dev_get_drvdata (dev); -u32 reg; - reg = (USBOTGSS_IRQMISC_OEVT | -USBOTGSS_IRQMISC_DRVVBUS_RISE | -USBOTGSS_IRQMISC_CHRGVBUS_RISE | -USBOTGSS_IRQMISC_DISCHRGVBUS_RISE | -USBOTGSS_IRQMISC_IDPULLUP_RISE | -USBOTGSS_IRQMISC_DRVVBUS_FALL | -USBOTGSS_IRQMISC_CHRGVBUS_FALL | -USBOTGSS_IRQMISC_DISCHRGVBUS_FALL | -USBOTGSS_IRQMISC_IDPULLUP_FALL ); - -dwc3_omap_write_irqmisc_set (omap, reg); +dwc3_omap_enable_irqs (omap); }static int dwc3_omap_suspend (struct device *dev)
Greg Kroah-Hartman
maintainerPATCH 210/319 usb: dwc3: gadget: Properly initialize LINK TRB
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jack Pham <[email protected]>
commit 1200a82a59b6aa65758ccc92c3447b98c53cd7a2 upstream.
On ISOC endpoints the last trb_pool entry used as a LINK TRB is not getting zeroed out correctly due to memset being called incorrectly and in the wrong place. If pool allocated from DMA was not zero-initialized to begin with this will result in the size and ctrl values being random garbage. Call memset correctly after assignment of the trb_link pointer.
--- drivers/usb/dwc3/gadget.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/dwc3/gadget.c +1 -2
@@ -615,12 +615,11 @@ static int __dwc3_gadget_ep_enable(strucif (!usb_endpoint_xfer_isoc (desc))return 0 ; -memset (&trb_link,0 ,sizeof (trb_link)); -/* Link TRB for ISOC. The HWO bit is never reset */ trb_st_hw = &dep->trb_pool[0 ]; trb_link = &dep->trb_pool[DWC3_TRB_NUM -1 ]; +memset (trb_link,0 ,sizeof (*trb_link)); trb_link->bpl =lower_32_bits (dwc3_trb_dma_offset (dep, trb_st_hw)); trb_link->bph =upper_32_bits (dwc3_trb_dma_offset (dep, trb_st_hw));
Greg Kroah-Hartman
maintainerPATCH 211/319 spi: pl022: Fix incorrect dma_unmap_sg
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ray Jui <[email protected]>
commit 3ffa6158f002e096d28ede71be4e0ee8ab20baa2 upstream.
When mapped RX DMA entries are unmapped in an error condition when DMA is firstly configured in the driver, the number of TX DMA entries was passed in, which is incorrect
--- drivers/spi/spi-pl022.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-pl022.c +1 -1
@@ -1074,7 +1074,7 @@ err_rxdesc: pl022->sgt_tx.nents, DMA_TO_DEVICE); err_tx_sgmap:dma_unmap_sg (rxchan->device->dev, pl022->sgt_rx.sgl, - pl022->sgt_tx.nents,DMA_FROM_DEVICE ); + pl022->sgt_rx.nents,DMA_FROM_DEVICE ); err_rx_sgmap:sg_free_table (&pl022->sgt_tx); err_alloc_tx_sg:
Greg Kroah-Hartman
maintainerPATCH 212/319 spi: fsl-dspi: Fix CTAR selection
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Stein <[email protected]>
commit 5cc7b04740effa5cc0af53f434134b5859d58b73 upstream.
There are only 4 CTAR registers (CTAR0 - CTAR3) so we can only use the lower 2 bits of the chip select to select a CTAR register. SPI_PUSHR_CTAS used the lower 3 bits which would result in wrong bit values if the chip selects 4/5 are used. For those chip selects SPI_CTAR even calculated offsets of non-existing registers.
--- drivers/spi/spi-fsl-dspi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-fsl-dspi.c +2 -2
@@ -46,7 +46,7 @@#define SPI_TCR 0x08 -#define SPI_CTAR (x) (0x0c + (x * 4)) +#define SPI_CTAR (x) (0x0c + (((x) & 0x3) * 4))#define SPI_CTAR_FMSZ (x) (((x) & 0x0000000f) << 27)#define SPI_CTAR_CPOL (x) ((x) << 26)#define SPI_CTAR_CPHA (x) ((x) << 25)
@@ -70,7 +70,7 @@#define SPI_PUSHR 0x34#define SPI_PUSHR_CONT (1 << 31) -#define SPI_PUSHR_CTAS (x) (((x) & 0x00000007) << 28) +#define SPI_PUSHR_CTAS (x) (((x) & 0x00000003) << 28)#define SPI_PUSHR_EOQ (1 << 27)#define SPI_PUSHR_CTCNT (1 << 26)#define SPI_PUSHR_PCS (x) (((1 << x) & 0x0000003f) << 16)
Greg Kroah-Hartman
maintainerPATCH 213/319 spi: pxa2xx: toggle clocks on suspend if not disabled by runtime PM
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Eremin-Solenikov <[email protected]>
commit 2b9375b91bef65b837bed61a05fb387159b38ddf upstream.
If PM_RUNTIME is enabled, it is easy to trigger the following backtrace on pxa2xx hosts:
------------[ cut here ]------------ WARNING: CPU: 0 PID: 1 at /home/lumag/linux/arch/arm/mach-pxa/clock.c:35 clk_disable+0xa0/0xa8() Modules linked in: CPU: 0 PID: 1 Comm: swapper Not tainted 3.17.0-00007-g1b3d2ee-dirty #104 [<c000de68>] (unwind_backtrace) from [<c000c078>] (show_stack+0x10/0x14) [<c000c078>] (show_stack) from [<c001d75c>] (warn_slowpath_common+0x6c/0x8c) [<c001d75c>] (warn_slowpath_common) from [<c001d818>] (warn_slowpath_null+0x1c/0x24) [<c001d818>] (warn_slowpath_null) from [<c0015e80>] (clk_disable+0xa0/0xa8) [<c0015e80>] (clk_disable) from [<c02507f8>] (pxa2xx_spi_suspend+0x2c/0x34) [<c02507f8>] (pxa2xx_spi_suspend) from [<c0200360>] (platform_pm_suspend+0x2c/0x54) [<c0200360>] (platform_pm_suspend) from [<c0207fec>] (dpm_run_callback.isra.14+0x2c/0x74) [<c0207fec>] (dpm_run_callback.isra.14) from [<c0209254>] (__device_suspend+0x120/0x2f8) [<c0209254>] (__device_suspend) from [<c0209a94>] (dpm_suspend+0x50/0x208) [<c0209a94>] (dpm_suspend) from [<c00455ac>] (suspend_devices_and_enter+0x8c/0x3a0) [<c00455ac>] (suspend_devices_and_enter) from [<c0045ad4>] (pm_suspend+0x214/0x2a8) [<c0045ad4>] (pm_suspend) from [<c04b5c34>] (test_suspend+0x14c/0x1dc) [<c04b5c34>] (test_suspend) from [<c000880c>] (do_one_initcall+0x8c/0x1fc) [<c000880c>] (do_one_initcall) from [<c04aecfc>] (kernel_init_freeable+0xf4/0x1b4) [<c04aecfc>] (kernel_init_freeable) from [<c0378078>] (kernel_init+0x8/0xec) [<c0378078>] (kernel_init) from [<c0009590>] (ret_from_fork+0x14/0x24) ---[ end trace 46524156d8faa4f6 ]---
This happens because suspend function tries to disable a clock that is already disabled by runtime_suspend callback. Add if (!pm_runtime_suspended()) checks to suspend/resume path.
--- drivers/spi/spi-pxa2xx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/spi/spi-pxa2xx.c +5 -2
@@ -1276,7 +1276,9 @@ static int pxa2xx_spi_suspend(struct devif (status !=0 )return status;write_SSCR0 (0 , drv_data->ioaddr); -clk_disable_unprepare (ssp->clk); + +if (!pm_runtime_suspended (dev)) +clk_disable_unprepare (ssp->clk);return 0 ; }
@@ -1290,7 +1292,8 @@ static int pxa2xx_spi_resume(struct devipxa2xx_spi_dma_resume (drv_data);/* Enable the SSP clock */ -clk_prepare_enable (ssp->clk); +if (!pm_runtime_suspended (dev)) +clk_prepare_enable (ssp->clk);/* Restore LPSS private register bits */ lpss_ssp_setup (drv_data);
Greg Kroah-Hartman
maintainerPATCH 214/319 uas: Add NO_ATA_1X for VIA VL711 devices
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 673029fe9c16c95600bdaca4760673527af32edf upstream.
Just like some Seagate enclosures, these devices do not seem to grok ata pass through commands.
--- drivers/usb/storage/unusual_uas.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/unusual_uas.h +7 -0
@@ -75,3 +75,10 @@ UNUSUAL_DEV(0x174c, 0x5106, 0x0000, 0x99 "ASM1051", USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_IGNORE_UAS), + +/* Reported-by: Hans de Goede <[email protected]> */ +UNUSUAL_DEV (0x2109 ,0x0711 ,0x0000 ,0x9999 , +"VIA" , +"VL711" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , + US_FL_NO_ATA_1X),
Greg Kroah-Hartman
maintainerPATCH 215/319 uas: Add US_FL_NO_ATA_1X quirk for 2 more Seagate models
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit d1d9548256fbdf2e049d6413a5266c41e73658ee upstream.
These drives hang when receiving ATA12 commands, so set the US_FL_NO_ATA_1X quirk to filter these out.
--- drivers/usb/storage/unusual_uas.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/usb/storage/unusual_uas.h +14 -0
@@ -54,6 +54,20 @@ UNUSUAL_DEV(0x0bc2, 0x3312, 0x0000, 0x99 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NO_ATA_1X), +/* Reported-by: Hans de Goede <[email protected]> */ +UNUSUAL_DEV (0x0bc2 ,0x3320 ,0x0000 ,0x9999 , +"Seagate" , +"Expansion Desk" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_NO_ATA_1X ), + +/* Reported-by: Bogdan Mihalcea <[email protected]> */ +UNUSUAL_DEV (0x0bc2 ,0xa003 ,0x0000 ,0x9999 , +"Seagate" , +"Backup Plus" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_NO_ATA_1X ), +/* https://bbs.archlinux.org/viewtopic.php?id=183190 */ UNUSUAL_DEV(0x0bc2, 0xab20, 0x0000, 0x9999, "Seagate",
Greg Kroah-Hartman
maintainerPATCH 216/319 uas: Add US_FL_NO_ATA_1X quirk for 1 more Seagate model
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit aee0ce3ae73c566ace9958302e001d3cbbb0a623 upstream.
These drives hang when receiving ATA12 commands, so set the US_FL_NO_ATA_1X quirk to filter these out.
--- drivers/usb/storage/unusual_uas.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/unusual_uas.h +7 -0
@@ -75,6 +75,13 @@ UNUSUAL_DEV(0x0bc2, 0xab20, 0x0000, 0x99 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NO_ATA_1X), +/* https://bbs.archlinux.org/viewtopic.php?id=183190 */ +UNUSUAL_DEV (0x0bc2 ,0xab21 ,0x0000 ,0x9999 , +"Seagate" , +"Backup+ BK" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_NO_ATA_1X ), +/* Reported-by: Claudio Bizzarri <[email protected]> */ UNUSUAL_DEV(0x152d, 0x0567, 0x0000, 0x9999, "JMicron",
Greg Kroah-Hartman
maintainerPATCH 217/319 usb: musb: cppi41: restart hrtimer only if not yet done
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit d2e6d62c9cbbc2da4211f672dbeea08960e29a80 upstream.
commit c58d80f52 ("usb: musb: Ensure that cppi41 timer gets armed on premature DMA TX irq") fixed hrtimer scheduling bug. There is one left which does not trigger that often.
The following scenario is still possible:
lock(&x->lock);
hrtimer_start(&x->t);
unlock(&x->lock);expires:
t->function();
lock(&x->lock);
lock(&x->lock); if (!hrtimer_queued(&x->t))
hrtimer_start(&x->t);
unlock(&x->lock);
if (!list_empty(x->early_tx_list))
ret = HRTIMER_RESTART;
-> hrtimer_forward_now(...)
} else
ret = HRTIMER_NORESTART;
unlock(&x->lock);and the timer callback returns HRTIMER_RESTART for an armed timer. This is wrong and we run into the BUG_ON() in __run_hrtimer(). This can happens on SMP or PREEMPT-RT.
The patch fixes the problem by only starting the timer if the timer is not yet queued.
[bigeasy: collected information and created a patch + description based
on it]
--- drivers/usb/musb/musb_cppi41.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/musb/musb_cppi41.c +2 -1
@@ -209,7 +209,8 @@ static enum hrtimer_restart cppi41_reche } } -if (!list_empty (&controller->early_tx_list)) { +if (!list_empty (&controller->early_tx_list) && + !hrtimer_is_queued (&controller->early_tx)) { ret =HRTIMER_RESTART ;hrtimer_forward_now (&controller->early_tx,ktime_set (0 ,50 *NSEC_PER_USEC ));
Greg Kroah-Hartman
maintainerPATCH 218/319 usb: musb: dsps: start OTG timer on resume again
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 53185b3a441a6cc9bb3f57e924342d249138dcd6 upstream.
Commit 468bcc2a2ca ("usb: musb: dsps: kill OTG timer on suspend") stopped the timer in suspend path but forgot the re-enable it in the resume path. This patch fixes the behaviour.
Fixes 468bcc2a2ca "usb: musb: dsps: kill OTG timer on suspend"
--- drivers/usb/musb/musb_dsps.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/musb/musb_dsps.c +3 -1
@@ -896,7 +896,9 @@ static int dsps_resume(struct device *dedsps_writel (mbase, wrp->mode, glue->context.mode);dsps_writel (mbase, wrp->tx_mode, glue->context.tx_mode);dsps_writel (mbase, wrp->rx_mode, glue->context.rx_mode); -setup_timer (&glue->timer, otg_timer, (unsigned long ) musb); +if (musb->xceiv->state ==OTG_STATE_B_IDLE && + musb->port_mode ==MUSB_PORT_MODE_DUAL_ROLE ) +mod_timer (&glue->timer, jiffies + wrp->poll_seconds *HZ );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 219/319 usb: gadget: f_fs: remove redundant ffs_data_get()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Baldyga <[email protected]>
commit a3058a5d82e296daaca07411c3738a9ddd79f302 upstream.
During FunctionFS bind, ffs_data_get() function was called twice (in functionfs_bind() and in ffs_do_functionfs_bind()), while on unbind ffs_data_put() was called once (in functionfs_unbind() function). In result refcount never reached value 0, and ffs memory resources has been never released.
Since ffs_data_get() call in ffs_do_functionfs_bind() is redundant and not neccessary, we remove it to have equal number of gets ans puts, and free allocated memory after refcount reach 0.
interface with backward compatibility)
--- drivers/usb/gadget/function/f_fs.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/gadget/function/f_fs.c +0 -2
@@ -2626,8 +2626,6 @@ static inline struct f_fs_opts *ffs_do_f func->conf = c; func->gadget = c->cdev->gadget; -ffs_data_get (func->ffs); -/* * in drivers/usb/gadget/configfs.c:configfs_composite_bind() * configurations are bound in sequence with list_for_each_entry,
Greg Kroah-Hartman
maintainerPATCH 220/319 usb: ffs: fix regression when quirk_ep_out_aligned_size flag is set
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Cohen <[email protected]>
commit c0d31b3c3d9a025b8d5a57c35671e60c5f388bf7 upstream.
The commit '2e4c7553cd usb: gadget: f_fs: add aio support' broke the quirk implemented to align buffer size to maxpacketsize on out endpoint. As result, functionfs does not work on Intel platforms using dwc3 driver (i.e. Bay Trail and Merrifield). This patch fixes the issue.
This code is based on a previous Qiuxu's patch.
--- drivers/usb/gadget/function/f_fs.c | 40 +++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-)
drivers/usb/gadget/function/f_fs.c +34 -6
@@ -648,15 +648,26 @@ static void ffs_user_copy_worker(structif (io_data->read && ret >0 ) {int i;size_t pos =0 ; + +/* +* Since req->length may be bigger than io_data->len (after +* being rounded up to maxpacketsize), we may end up with more +* data then user space has space for. +*/ + ret =min_t (int, ret, io_data->len); +use_mm (io_data->mm);for (i =0 ; i < io_data->nr_segs; i++) { +size_t len =min_t (size_t, ret - pos, + io_data->iovec[i].iov_len); +if (!len) +break ;if (unlikely (copy_to_user (io_data->iovec[i].iov_base, - &io_data->buf[pos], - io_data->iovec[i].iov_len))) { + &io_data->buf[pos], len))) { ret = -EFAULT ;break ; } - pos += io_data->iovec[i].iov_len; + pos += len; }unuse_mm (io_data->mm); }
@@ -688,7 +699,7 @@ static ssize_t ffs_epfile_io(struct filestruct ffs_epfile *epfile = file->private_data;struct ffs_ep *ep;char *data =NULL ; -ssize_t ret, data_len; +ssize_t ret, data_len = -EINVAL ;int halt;/* Are we still active? */
@@ -788,13 +799,30 @@ static ssize_t ffs_epfile_io(struct file/* Fire the request */ struct usb_request *req; +/* +* Sanity Check: even though data_len can't be used +* uninitialized at the time I write this comment, some +* compilers complain about this situation. +* In order to keep the code clean from warnings, data_len is +* being initialized to -EINVAL during its declaration, which +* means we can't rely on compiler anymore to warn no future +* changes won't result in data_len being used uninitialized. +* For such reason, we're adding this redundant sanity check +* here. +*/ +if (unlikely (data_len == -EINVAL )) { +WARN (1 ,"%s: data_len == -EINVAL\n" , __func__); + ret = -EINVAL ; + goto error_lock; + } +if (io_data->aio) { req =usb_ep_alloc_request (ep->ep,GFP_KERNEL );if (unlikely (!req)) goto error_lock; req->buf = data; - req->length = io_data->len; + req->length = data_len; io_data->buf = data; io_data->ep = ep->ep;
@@ -816,7 +844,7 @@ static ssize_t ffs_epfile_io(struct file req = ep->req; req->buf = data; - req->length = io_data->len; + req->length = data_len; req->context = &done; req->complete = ffs_epfile_io_complete;
Greg Kroah-Hartman
maintainerPATCH 221/319 usb: chipidea: Fix oops when removing the ci_hdrc module
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Torsten Fleischer <[email protected]>
commit 9680b60ed79edaf52f84b65cbb20859bbb26cb68 upstream.
The call of 'kfree(ci->hw_bank.regmap)' in ci_hdrc_remove() sometimes causes a kernel oops when removing the ci_hdrc module.
Since there is no separate memory allocated for the ci->hw_bank.regmap array, there is no need to free it.
--- drivers/usb/chipidea/core.c | 1 - 1 file changed, 1 deletion(-)
drivers/usb/chipidea/core.c +0 -1
@@ -732,7 +732,6 @@ static int ci_hdrc_remove(struct platforci_role_destroy (ci);ci_hdrc_enter_lpm (ci, true);usb_phy_shutdown (ci->transceiver); -kfree (ci->hw_bank.regmap);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 223/319 USB: quirks: enable device-qualifier quirk for Elan Touchscreen
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit c68929f75dfcb6354918862b91b5778585de1fa5 upstream.
Enable device-qualifier quirk for Elan Touchscreen, which often fails to handle requests for the device_descriptor.
Note that the device sometimes do respond properly with a Request Error (three times as USB core retries), but usually fails to respond at all. When this happens any further descriptor requests also fails, for example:
[ 1528.688934] usb 2-7: new full-speed USB device number 4 using xhci_hcd [ 1530.945588] usb 2-7: unable to read config index 0 descriptor/start: -71 [ 1530.945592] usb 2-7: can't read configurations, error -71
This has been observed repeating for over a minute before eventual successful enumeration.
--- drivers/usb/core/quirks.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/core/quirks.c +4 -0
@@ -93,6 +93,10 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x04e8, 0x6601), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS }, + /* Elan Touchscreen */ + { USB_DEVICE(0x04f3, 0x0089), .driver_info = + USB_QUIRK_DEVICE_QUALIFIER }, + /* Roland SC-8820 */ { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
Greg Kroah-Hartman
maintainerPATCH 224/319 USB: quirks: enable device-qualifier quirk for another Elan touchscreen
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adel Gadllah <[email protected]>
commit 876af5d454548be40327ba9efea4bc92a8575019 upstream.
Currently this quirk is enabled for the model with the device id 0x0089, it is needed for the 0x009b model, which is found on the Fujitsu Lifebook u904 as well.
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -97,6 +97,9 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x04f3, 0x0089), .driver_info = USB_QUIRK_DEVICE_QUALIFIER }, + { USB_DEVICE(0x04f3, 0x009b), .driver_info = + USB_QUIRK_DEVICE_QUALIFIER }, + /* Roland SC-8820 */ { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
Greg Kroah-Hartman
maintainerPATCH 225/319 USB: quirks: enable device-qualifier quirk for yet another Elan touchscreen
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adel Gadllah <[email protected]>
commit d749947561af5996ccc076b2ffcc5f48b1be5d74 upstream.
Yet another device affected by this.
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -100,6 +100,9 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x04f3, 0x009b), .driver_info = USB_QUIRK_DEVICE_QUALIFIER }, + { USB_DEVICE(0x04f3, 0x016f), .driver_info = + USB_QUIRK_DEVICE_QUALIFIER }, + /* Roland SC-8820 */ { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
Greg Kroah-Hartman
maintainerPATCH 226/319 HID: usbhid: add always-poll quirk
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 0b750b3baa2d64f1b77aecc10f20deeb28efe60d upstream.
Add quirk to make sure that a device is always polled for input events even if it hasn't been opened.
This is needed for devices that disconnects from the bus unless the interrupt endpoint has been polled at least once or when not responding to an input event (e.g. after having shut down X).
--- drivers/hid/usbhid/hid-core.c | 26 +++++++++++++++++++++++--- include/linux/hid.h | 1 + 2 files changed, 24 insertions(+), 3 deletions(-)
drivers/hid/usbhid/hid-core.c +23 -3
@@ -82,7 +82,7 @@ static int hid_start_in(struct hid_devicstruct usbhid_device *usbhid = hid->driver_data;spin_lock_irqsave (&usbhid->lock, flags); -if (hid->open >0 && +if ((hid->open >0 || hid->quirks &HID_QUIRK_ALWAYS_POLL ) && !test_bit (HID_DISCONNECTED , &usbhid->iofl) && !test_bit (HID_SUSPENDED , &usbhid->iofl) && !test_and_set_bit (HID_IN_RUNNING , &usbhid->iofl)) {
@@ -292,6 +292,8 @@ static void hid_irq_in(struct urb *urb)case 0 :/* success */ usbhid_mark_busy (usbhid); usbhid->retry_delay =0 ; +if ((hid->quirks &HID_QUIRK_ALWAYS_POLL ) && !hid->open) +break ;hid_input_report (urb->context,HID_INPUT_REPORT , urb->transfer_buffer, urb->actual_length,1 );
@@ -735,8 +737,10 @@ void usbhid_close(struct hid_device *hidif (!--hid->open) {spin_unlock_irq (&usbhid->lock);hid_cancel_delayed_stuff (usbhid); -usb_kill_urb (usbhid->urbin); - usbhid->intf->needs_remote_wakeup =0 ; +if (!(hid->quirks &HID_QUIRK_ALWAYS_POLL )) { +usb_kill_urb (usbhid->urbin); + usbhid->intf->needs_remote_wakeup =0 ; + } }else {spin_unlock_irq (&usbhid->lock); }
@@ -1134,6 +1138,19 @@ static int usbhid_start(struct hid_devicset_bit (HID_STARTED , &usbhid->iofl); +if (hid->quirks &HID_QUIRK_ALWAYS_POLL ) { + ret =usb_autopm_get_interface (usbhid->intf); +if (ret) + goto fail; + usbhid->intf->needs_remote_wakeup =1 ; + ret =hid_start_in (hid); +if (ret) { +dev_err (&hid->dev, +"failed to start in urb: %d\n" , ret); + } +usb_autopm_put_interface (usbhid->intf); + } +/* Some keyboards don't work until their LEDs have been set. * Since BIOSes do set the LEDs, it must be safe for any device * that supports the keyboard boot protocol.
@@ -1166,6 +1183,9 @@ static void usbhid_stop(struct hid_devicif (WARN_ON (!usbhid))return ; +if (hid->quirks &HID_QUIRK_ALWAYS_POLL ) + usbhid->intf->needs_remote_wakeup =0 ; +clear_bit (HID_STARTED , &usbhid->iofl);spin_lock_irq (&usbhid->lock);/* Sync with error and led handlers */ set_bit (HID_DISCONNECTED , &usbhid->iofl);
include/linux/hid.h +1 -0
@@ -287,6 +287,7 @@ struct hid_item {#define HID_QUIRK_HIDINPUT_FORCE 0x00000080#define HID_QUIRK_NO_EMPTY_INPUT 0x00000100#define HID_QUIRK_NO_INIT_INPUT_REPORTS 0x00000200 +#define HID_QUIRK_ALWAYS_POLL 0x00000400#define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000#define HID_QUIRK_SKIP_OUTPUT_REPORT_ID 0x00020000#define HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP 0x00040000
Greg Kroah-Hartman
maintainerPATCH 227/319 HID: usbhid: enable always-poll quirk for Elan Touchscreen
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit bfe3c873e978d78b542a5852575dd74f4d1a5838 upstream.
Enable the always-poll quirk for Elan Touchscreens found on some recent Samsung laptops.
Without this quirk the device keeps disconnecting from the bus (and is re-enumerated) unless opened (and kept open, should an input event occur).
Note that while the device can be run-time suspended, the autosuspend timeout must be high enough to allow the device to be polled at least once before being suspended. Specifically, using autosuspend_delay_ms=0 will still cause the device to disconnect on input events.
--- drivers/hid/hid-ids.h | 3 +++ drivers/hid/usbhid/hid-quirks.c | 1 + 2 files changed, 4 insertions(+)
drivers/hid/hid-ids.h +3 -0
@@ -296,6 +296,9 @@#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_73F7 0x73f7#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001 0xa001 +#define USB_VENDOR_ID_ELAN 0x04f3 +#define USB_DEVICE_ID_ELAN_TOUCHSCREEN 0x0089 +#define USB_VENDOR_ID_ELECOM 0x056e#define USB_DEVICE_ID_ELECOM_BM084 0x0061
drivers/hid/usbhid/hid-quirks.c +1 -0
@@ -70,6 +70,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK, HID_QUIRK_NOGET }, { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET }, { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
Greg Kroah-Hartman
maintainerPATCH 228/319 HID: usbhid: fix PIXART optical mouse
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 4980f95755e2966b30ac70d1841f4db66d1a8a22 upstream.
This mouse keeps disconnecting in runlevel 3. It needs the ALWAYS_POLL quirk.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/usbhid/hid-quirks.c | 1 + 2 files changed, 2 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -736,6 +736,7 @@#define USB_DEVICE_ID_PI_ENGINEERING_VEC_USB_FOOTPEDAL 0xff#define USB_VENDOR_ID_PIXART 0x093a +#define USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE 0x2510#define USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN 0x8001#define USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1 0x8002#define USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2 0x8003
drivers/hid/usbhid/hid-quirks.c +1 -0
@@ -80,6 +80,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_1610, HID_QUIRK_NOGET }, { USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_1640, HID_QUIRK_NOGET }, + { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2, HID_QUIRK_NO_INIT_REPORTS },
Greg Kroah-Hartman
maintainerPATCH 229/319 HID: usbhid: add another mouse that needs QUIRK_ALWAYS_POLL
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 5235166fbc332c8b5dcf49e3a498a8b510a77449 upstream.
There is a second mouse sharing the same vendor strings but different IDs.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/usbhid/hid-quirks.c | 1 + 2 files changed, 2 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -736,6 +736,7 @@#define USB_DEVICE_ID_PI_ENGINEERING_VEC_USB_FOOTPEDAL 0xff#define USB_VENDOR_ID_PIXART 0x093a +#define USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE_ID2 0x0137#define USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE 0x2510#define USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN 0x8001#define USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1 0x8002
drivers/hid/usbhid/hid-quirks.c +1 -0
@@ -81,6 +81,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_1610, HID_QUIRK_NOGET }, { USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_1640, HID_QUIRK_NOGET }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL }, + { USB_VENDOR_ID_KYE, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE_ID2, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2, HID_QUIRK_NO_INIT_REPORTS },
Greg Kroah-Hartman
maintainerPATCH 230/319 HID: usbhid: enable always-poll quirk for Elan Touchscreen 009b
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adel Gadllah <[email protected]>
commit 29d05c2ecf396161ef2938a0635707ef5685ef58 upstream.
This device needs the quirk as well.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/usbhid/hid-quirks.c | 1 + 2 files changed, 2 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -298,6 +298,7 @@#define USB_VENDOR_ID_ELAN 0x04f3#define USB_DEVICE_ID_ELAN_TOUCHSCREEN 0x0089 +#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B 0x009b#define USB_VENDOR_ID_ELECOM 0x056e#define USB_DEVICE_ID_ELECOM_BM084 0x0061
drivers/hid/usbhid/hid-quirks.c +1 -0
@@ -71,6 +71,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET }, { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL }, + { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
Greg Kroah-Hartman
maintainerPATCH 231/319 HID: usbhid: enable always-poll quirk for Elan Touchscreen 016f
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adel Gadllah <[email protected]>
commit 1af39588f84c7c18f8c6d88342f36513a4ce383c upstream.
This device needs the quirk as well.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/usbhid/hid-quirks.c | 1 + 2 files changed, 2 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -299,6 +299,7 @@#define USB_VENDOR_ID_ELAN 0x04f3#define USB_DEVICE_ID_ELAN_TOUCHSCREEN 0x0089#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B 0x009b +#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F 0x016f#define USB_VENDOR_ID_ELECOM 0x056e#define USB_DEVICE_ID_ELECOM_BM084 0x0061
drivers/hid/usbhid/hid-quirks.c +1 -0
@@ -72,6 +72,7 @@ static const struct hid_blacklist { { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B, HID_QUIRK_ALWAYS_POLL }, + { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F, HID_QUIRK_ALWAYS_POLL }, { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS }, { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
Greg Kroah-Hartman
maintainerPATCH 232/319 usb: gadget: udc: core: fix kernel oops with soft-connect
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit bfa6b18c680450c17512c741ed1d818695747621 upstream.
Currently, there's no guarantee that udc->driver will be valid when using soft_connect sysfs interface. In fact, we can very easily trigger a NULL pointer dereference by trying to disconnect when a gadget driver isn't loaded.
Fix this bug:
~# echo disconnect > soft_connect
[ 33.685743] Unable to handle kernel NULL pointer dereference at virtual address 00000014 [ 33.694221] pgd = ed0cc000 [ 33.697174] [00000014] *pgd=ae351831, *pte=00000000, *ppte=00000000 [ 33.703766] Internal error: Oops: 17 [#1] SMP ARM [ 33.708697] Modules linked in: xhci_plat_hcd xhci_hcd snd_soc_davinci_mcasp snd_soc_tlv320aic3x snd_soc_edma snd_soc_omap snd_soc_evm snd_soc_core dwc3 snd_compress snd_pcm_dmaengine snd_pcm snd_timer snd lis3lv02d_i2c matrix_keypad lis3lv02d dwc3_omap input_polldev soundcore [ 33.734372] CPU: 0 PID: 1457 Comm: bash Not tainted 3.17.0-09740-ga93416e-dirty #345 [ 33.742457] task: ee71ce00 ti: ee68a000 task.ti: ee68a000 [ 33.748116] PC is at usb_udc_softconn_store+0xa4/0xec [ 33.753416] LR is at mark_held_locks+0x78/0x90 [ 33.758057] pc : [<c04df128>] lr : [<c00896a4>] psr: 20000013 [ 33.758057] sp : ee68bec8 ip : c0c00008 fp : ee68bee4 [ 33.770050] r10: ee6b394c r9 : ee68bf80 r8 : ee6062c0 [ 33.775508] r7 : 00000000 r6 : ee6062c0 r5 : 0000000b r4 : ee739408 [ 33.782346] r3 : 00000000 r2 : 00000000 r1 : ee71d390 r0 : ee664170 [ 33.789168] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 33.796636] Control: 10c5387d Table: ad0cc059 DAC: 00000015 [ 33.802638] Process bash (pid: 1457, stack limit = 0xee68a248) [ 33.808740] Stack: (0xee68bec8 to 0xee68c000) [ 33.813299] bec0: 0000000b c0411284 ee6062c0 00000000 ee68bef4 ee68bee8 [ 33.821862] bee0: c04112ac c04df090 ee68bf14 ee68bef8 c01c2868 c0411290 0000000b ee6b3940 [ 33.830419] bf00: 00000000 00000000 ee68bf4c ee68bf18 c01c1a24 c01c2818 00000000 00000000 [ 33.838990] bf20: ee61b940 ee2f47c0 0000000b 000ce408 ee68bf80 c000f304 ee68a000 00000000 [ 33.847544] bf40: ee68bf7c ee68bf50 c0152dd8 c01c1960 ee68bf7c c0170af8 ee68bf7c ee2f47c0 [ 33.856099] bf60: ee2f47c0 000ce408 0000000b c000f304 ee68bfa4 ee68bf80 c0153330 c0152d34 [ 33.864653] bf80: 00000000 00000000 0000000b 000ce408 b6e7fb50 00000004 00000000 ee68bfa8 [ 33.873204] bfa0: c000f080 c01532e8 0000000b 000ce408 00000001 000ce408 0000000b 00000000 [ 33.881763] bfc0: 0000000b 000ce408 b6e7fb50 00000004 0000000b 00000000 000c5758 00000000 [ 33.890319] bfe0: 00000000 bec2c924 b6de422d b6e1d226 40000030 00000001 75716d2f 00657565 [ 33.898890] [<c04df128>] (usb_udc_softconn_store) from [<c04112ac>] (dev_attr_store+0x28/0x34) [ 33.907920] [<c04112ac>] (dev_attr_store) from [<c01c2868>] (sysfs_kf_write+0x5c/0x60) [ 33.916200] [<c01c2868>] (sysfs_kf_write) from [<c01c1a24>] (kernfs_fop_write+0xd0/0x194) [ 33.924773] [<c01c1a24>] (kernfs_fop_write) from [<c0152dd8>] (vfs_write+0xb0/0x1bc) [ 33.932874] [<c0152dd8>] (vfs_write) from [<c0153330>] (SyS_write+0x54/0xb0) [ 33.940247] [<c0153330>] (SyS_write) from [<c000f080>] (ret_fast_syscall+0x0/0x48) [ 33.948160] Code: e1a01007 e12fff33 e5140004 e5143008 (e5933014) [ 33.954625] ---[ end trace f849bead94eab7ea ]---
--- drivers/usb/gadget/udc/udc-core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/gadget/udc/udc-core.c +5 -0
@@ -458,6 +458,11 @@ static ssize_t usb_udc_softconn_store(st { struct usb_udc *udc = container_of(dev, struct usb_udc, dev); +if (!udc->driver) { +dev_err (dev,"soft-connect without a gadget driver\n" ); +return -EOPNOTSUPP ; + } +if (sysfs_streq (buf,"connect" )) {usb_gadget_udc_start (udc->gadget, udc->driver);usb_gadget_connect (udc->gadget);
Greg Kroah-Hartman
maintainerPATCH 233/319 ALSA: usb-audio: Fix device_del() sysfs warnings at disconnect
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 0725dda207e95ff25f1aa01432250323e0ec49d6 upstream.
Some USB-audio devices show weird sysfs warnings at disconnecting the devices, e.g.
usb 1-3: USB disconnect, device number 3
------------[ cut here ]------------ WARNING: CPU: 0 PID: 973 at fs/sysfs/group.c:216 device_del+0x39/0x180() sysfs group ffffffff8183df40 not found for kobject 'midiC1D0' Call Trace: [<ffffffff814a3e38>] ? dump_stack+0x49/0x71 [<ffffffff8103cb72>] ? warn_slowpath_common+0x82/0xb0 [<ffffffff8103cc55>] ? warn_slowpath_fmt+0x45/0x50 [<ffffffff813521e9>] ? device_del+0x39/0x180 [<ffffffff81352339>] ? device_unregister+0x9/0x20 [<ffffffff81352384>] ? device_destroy+0x34/0x40 [<ffffffffa00ba29f>] ? snd_unregister_device+0x7f/0xd0 [snd] [<ffffffffa025124e>] ? snd_rawmidi_dev_disconnect+0xce/0x100 [snd_rawmidi] [<ffffffffa00c0192>] ? snd_device_disconnect+0x62/0x90 [snd] [<ffffffffa00c025c>] ? snd_device_disconnect_all+0x3c/0x60 [snd] [<ffffffffa00bb574>] ? snd_card_disconnect+0x124/0x1a0 [snd] [<ffffffffa02e54e8>] ? usb_audio_disconnect+0x88/0x1c0 [snd_usb_audio] [<ffffffffa015260e>] ? usb_unbind_interface+0x5e/0x1b0 [usbcore] [<ffffffff813553e9>] ? __device_release_driver+0x79/0xf0 [<ffffffff81355485>] ? device_release_driver+0x25/0x40 [<ffffffff81354e11>] ? bus_remove_device+0xf1/0x130 [<ffffffff813522b9>] ? device_del+0x109/0x180 [<ffffffffa01501d5>] ? usb_disable_device+0x95/0x1f0 [usbcore] [<ffffffffa014634f>] ? usb_disconnect+0x8f/0x190 [usbcore] [<ffffffffa0149179>] ? hub_thread+0x539/0x13a0 [usbcore] [<ffffffff810669f5>] ? sched_clock_local+0x15/0x80 [<ffffffff81066c98>] ? sched_clock_cpu+0xb8/0xd0 [<ffffffff81070730>] ? bit_waitqueue+0xb0/0xb0 [<ffffffffa0148c40>] ? usb_port_resume+0x430/0x430 [usbcore] [<ffffffffa0148c40>] ? usb_port_resume+0x430/0x430 [usbcore] [<ffffffff8105973e>] ? kthread+0xce/0xf0 [<ffffffff81059670>] ? kthread_create_on_node+0x1c0/0x1c0 [<ffffffff814a8b7c>] ? ret_from_fork+0x7c/0xb0 [<ffffffff81059670>] ? kthread_create_on_node+0x1c0/0x1c0 ---[ end trace 40b1928d1136b91e ]---
This comes from the fact that usb-audio driver may receive the disconnect callback multiple times, per each usb interface. When a device has both audio and midi interfaces, it gets called twice, and currently the driver tries to release resources at the last call. At this point, the first parent interface has been already deleted, thus deleting a child of the first parent hits such a warning.
For fixing this problem, we need to call snd_card_disconnect() and cancel pending operations at the very first disconnect while the release of the whole objects waits until the last disconnect call.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=80931
--- sound/usb/card.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
sound/usb/card.c +7 -2
@@ -591,18 +591,19 @@ static void snd_usb_audio_disconnect(str {struct snd_card *card;struct list_head *p; +bool was_shutdown;if (chip == (void *)-1L )return ; card = chip->card;down_write (&chip->shutdown_rwsem); + was_shutdown = chip->shutdown; chip->shutdown =1 ;up_write (&chip->shutdown_rwsem);mutex_lock (®ister_mutex); - chip->num_interfaces--; -if (chip->num_interfaces <=0 ) { +if (!was_shutdown) {struct snd_usb_endpoint *ep;snd_card_disconnect (card);
@@ -622,6 +623,10 @@ static void snd_usb_audio_disconnect(strlist_for_each (p, &chip->mixer_list) {snd_usb_mixer_disconnect (p); } + } + + chip->num_interfaces--; +if (chip->num_interfaces <=0 ) { usb_chip[chip->index] =NULL ;mutex_unlock (®ister_mutex);snd_card_free_when_closed (card);
Greg Kroah-Hartman
maintainerPATCH 234/319 usb-storage: handle a skipped data phase
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 93c9bf4d1838d5851a18ca398b0ad66397f05056 upstream.
Sometimes mass-storage devices using the Bulk-only transport will mistakenly skip the data phase of a command. Rather than sending the data expected by the host or sending a zero-length packet, they go directly to the status phase and send the CSW.
This causes problems for usb-storage, for obvious reasons. The driver will interpret the CSW as a short data transfer and will wait to receive a CSW. The device won't have anything left to send, so the command eventually times out.
The SCSI layer doesn't retry commands after they time out (this is a relatively recent change). Therefore we should do our best to detect a skipped data phase and handle it promptly.
This patch adds code to do that. If usb-storage receives a short 13-byte data transfer from the device, and if the first four bytes of the data match the CSW signature, the driver will set the residue to the full transfer length and interpret the data as a CSW.
This fixes Bugzilla #86611.
--- drivers/usb/storage/transport.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/usb/storage/transport.c +26 -0
@@ -1118,6 +1118,31 @@ int usb_stor_Bulk_transport(struct scsi_*/ if (result ==USB_STOR_XFER_LONG ) fake_sense =1 ; + +/* +* Sometimes a device will mistakenly skip the data phase +* and go directly to the status phase without sending a +* zero-length packet. If we get a 13-byte response here, +* check whether it really is a CSW. +*/ +if (result ==USB_STOR_XFER_SHORT && + srb->sc_data_direction ==DMA_FROM_DEVICE && + transfer_length -scsi_get_resid (srb) == +US_BULK_CS_WRAP_LEN ) { +struct scatterlist *sg =NULL ; +unsigned int offset =0 ; + +if (usb_stor_access_xfer_buf ((unsigned char *) bcs, +US_BULK_CS_WRAP_LEN , srb, &sg, + &offset,FROM_XFER_BUF ) == +US_BULK_CS_WRAP_LEN && + bcs->Signature == +cpu_to_le32 (US_BULK_CS_SIGN )) { +usb_stor_dbg (us,"Device skipped data phase\n" ); +scsi_set_resid (srb, transfer_length); + goto skipped_data_phase; + } + } }/* See flow chart on pg 15 of the Bulk Only Transport spec for
@@ -1153,6 +1178,7 @@ int usb_stor_Bulk_transport(struct scsi_if (result !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ; + skipped_data_phase:/* check bulk status */ residue =le32_to_cpu (bcs->Residue); usb_stor_dbg(us, "Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
Greg Kroah-Hartman
maintainerPATCH 235/319 USB: opticon: fix non-atomic allocation in write path
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit e681286de221af78fc85db9222b6a203148c005a upstream.
Write may be called from interrupt context so make sure to use GFP_ATOMIC for all allocations in write.
--- drivers/usb/serial/opticon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/opticon.c +1 -1
@@ -215,7 +215,7 @@ static int opticon_write(struct tty_stru/* The connected devices do not have a bulk write endpoint, * to transmit data to de barcode device the control endpoint is used */ - dr =kmalloc (sizeof (struct usb_ctrlrequest ),GFP_NOIO ); + dr =kmalloc (sizeof (struct usb_ctrlrequest ),GFP_ATOMIC );if (!dr) { count = -ENOMEM ; goto error_no_dr;
Greg Kroah-Hartman
maintainerPATCH 236/319 usb: Do not allow usb_alloc_streams on unconfigured devices
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 90a646c770c50cc206ceba0d7b50453c46c13c36 upstream.
This commit fixes the following oops:
[10238.622067] scsi host3: uas_eh_bus_reset_handler start [10240.766164] usb 3-4: reset SuperSpeed USB device number 3 using xhci_hcd [10245.779365] usb 3-4: device descriptor read/8, error -110 [10245.883331] usb 3-4: reset SuperSpeed USB device number 3 using xhci_hcd [10250.897603] usb 3-4: device descriptor read/8, error -110 [10251.058200] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 [10251.058244] IP: [<ffffffff815ac6e1>] xhci_check_streams_endpoint+0x91/0x140 <snip> [10251.059473] Call Trace: [10251.059487] [<ffffffff815aca6c>] xhci_calculate_streams_and_bitmask+0xbc/0x130 [10251.059520] [<ffffffff815aeb5f>] xhci_alloc_streams+0x10f/0x5a0 [10251.059548] [<ffffffff810a4685>] ? check_preempt_curr+0x75/0xa0 [10251.059575] [<ffffffff810a46dc>] ? ttwu_do_wakeup+0x2c/0x100 [10251.059601] [<ffffffff810a49e6>] ? ttwu_do_activate.constprop.111+0x66/0x70 [10251.059635] [<ffffffff815779ab>] usb_alloc_streams+0xab/0xf0 [10251.059662] [<ffffffffc0616b48>] uas_configure_endpoints+0x128/0x150 [uas] [10251.059694] [<ffffffffc0616bac>] uas_post_reset+0x3c/0xb0 [uas] [10251.059722] [<ffffffff815727d9>] usb_reset_device+0x1b9/0x2a0 [10251.059749] [<ffffffffc0616f42>] uas_eh_bus_reset_handler+0xb2/0x190 [uas] [10251.059781] [<ffffffff81514293>] scsi_try_bus_reset+0x53/0x110 [10251.059808] [<ffffffff815163b7>] scsi_eh_bus_reset+0xf7/0x270
<snip>
The problem is the following call sequence (simplified):
1) usb_reset_device
2) usb_reset_and_verify_device
2) hub_port_init
3) hub_port_finish_reset
3) xhci_discover_or_reset_device
This frees xhci->devs[slot_id]->eps[ep_index].ring for all eps but 0
4) usb_get_device_descriptor
This fails
5) hub_port_init fails
6) usb_reset_and_verify_device fails, does not restore device config
7) uas_post_reset
8) xhci_alloc_streams
NULL deref on the free-ed ring
This commit fixes this by not allowing usb_alloc_streams to continue if the device is not configured.
Note that we do allow usb_free_streams to continue after a (logical) disconnect, as it is necessary to explicitly free the streams at the xhci controller level.
--- drivers/usb/core/hcd.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/core/hcd.c +2 -0
@@ -2057,6 +2057,8 @@ int usb_alloc_streams(struct usb_interfareturn -EINVAL ;if (dev->speed !=USB_SPEED_SUPER )return -EINVAL ; +if (dev->state <USB_STATE_CONFIGURED ) +return -ENODEV ;for (i =0 ; i < num_eps; i++) {/* Streams only apply to bulk endpoints. */
Greg Kroah-Hartman
maintainerPATCH 237/319 USB: kobil_sct: fix non-atomic allocation in write path
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 191252837626fca0de694c18bb2aa64c118eda89 upstream.
Write may be called from interrupt context so make sure to use GFP_ATOMIC for all allocations in write.
--- drivers/usb/serial/kobil_sct.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/serial/kobil_sct.c +3 -2
@@ -335,7 +335,8 @@ static int kobil_write(struct tty_struct port->interrupt_out_urb->transfer_buffer_length = length; priv->cur_pos = priv->cur_pos + length; - result =usb_submit_urb (port->interrupt_out_urb,GFP_NOIO ); + result =usb_submit_urb (port->interrupt_out_urb, +GFP_ATOMIC );dev_dbg (&port->dev,"%s - Send write URB returns: %i\n" , __func__, result); todo = priv->filled - priv->cur_pos;
@@ -350,7 +351,7 @@ static int kobil_write(struct tty_structif (priv->device_type ==KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type ==KOBIL_ADAPTER_K_PRODUCT_ID ) { result =usb_submit_urb (port->interrupt_in_urb, -GFP_NOIO ); +GFP_ATOMIC );dev_dbg (&port->dev,"%s - Send read URB returns: %i\n" , __func__, result); } }
Greg Kroah-Hartman
maintainerPATCH 238/319 usb: Remove references to non-existent PLAT_S5P symbol
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sylwester Nawrocki <[email protected]>
commit cd6e245a2d061a8367e37aaece32cf3fc922de80 upstream.
The PLAT_S5P Kconfig symbol was removed in commit d78c16ccde96 ("ARM: SAMSUNG: Remove remaining legacy code"). There are still some references left, fix that by replacing them with ARCH_S5PV210.
--- drivers/usb/host/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/Kconfig +2 -2
@@ -220,7 +220,7 @@ config USB_EHCI_SH config USB_EHCI_EXYNOS tristate "EHCI support for Samsung S5P/EXYNOS SoC Series" - depends on PLAT_S5P || ARCH_EXYNOS + depends on ARCH_S5PV210 || ARCH_EXYNOS help Enable support for the Samsung Exynos SOC's on-chip EHCI controller.
@@ -527,7 +527,7 @@ config USB_OHCI_SH config USB_OHCI_EXYNOS tristate "OHCI support for Samsung S5P/EXYNOS SoC Series" - depends on PLAT_S5P || ARCH_EXYNOS + depends on ARCH_S5PV210 || ARCH_EXYNOS help Enable support for the Samsung Exynos SOC's on-chip OHCI controller.
Greg Kroah-Hartman
maintainerPATCH 239/319 ima: check xattr value length and type in the ima_inode_setxattr()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Kasatkin <[email protected]>
commit a48fda9de94500a3152a56b723d0a64ae236547c upstream.
ima_inode_setxattr() can be called with no value. Function does not check the length so that following command can be used to produce kernel oops: setfattr -n security.ima FOO. This patch fixes it.
Changes in v3:
* for stable reverted "allow setting hash only in fix or log mode" It will be a separate patch.
Changes in v2:
* testing validity of xattr type
* allow setting hash only in fix or log mode (Mimi)
[ 261.562522] BUG: unable to handle kernel NULL pointer dereference at (null) [ 261.564109] IP: [<ffffffff812af272>] ima_inode_setxattr+0x3e/0x5a [ 261.564109] PGD 3112f067 PUD 42965067 PMD 0 [ 261.564109] Oops: 0000 [#1] SMP [ 261.564109] Modules linked in: bridge stp llc evdev serio_raw i2c_piix4 button fuse [ 261.564109] CPU: 0 PID: 3299 Comm: setxattr Not tainted 3.16.0-kds+ #2924 [ 261.564109] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 261.564109] task: ffff8800428c2430 ti: ffff880042be0000 task.ti: ffff880042be0000 [ 261.564109] RIP: 0010:[<ffffffff812af272>] [<ffffffff812af272>] ima_inode_setxattr+0x3e/0x5a [ 261.564109] RSP: 0018:ffff880042be3d50 EFLAGS: 00010246 [ 261.564109] RAX: 0000000000000001 RBX: 0000000000000000 RCX: 0000000000000015 [ 261.564109] RDX: 0000001500000000 RSI: 0000000000000000 RDI: ffff8800375cc600 [ 261.564109] RBP: ffff880042be3d68 R08: 0000000000000000 R09: 00000000004d6256 [ 261.564109] R10: 0000000000000000 R11: 0000000000000000 R12: ffff88002149ba00 [ 261.564109] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 [ 261.564109] FS: 00007f6c1e219740(0000) GS:ffff88005da00000(0000) knlGS:0000000000000000 [ 261.564109] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 261.564109] CR2: 0000000000000000 CR3: 000000003b35a000 CR4: 00000000000006f0 [ 261.564109] Stack: [ 261.564109] ffff88002149ba00 ffff880042be3df8 0000000000000000 ffff880042be3d98 [ 261.564109] ffffffff812a101b ffff88002149ba00 ffff880042be3df8 0000000000000000 [ 261.564109] 0000000000000000 ffff880042be3de0 ffffffff8116d08a ffff880042be3dc8 [ 261.564109] Call Trace: [ 261.564109] [<ffffffff812a101b>] security_inode_setxattr+0x48/0x6a [ 261.564109] [<ffffffff8116d08a>] vfs_setxattr+0x6b/0x9f [ 261.564109] [<ffffffff8116d1e0>] setxattr+0x122/0x16c [ 261.564109] [<ffffffff811687e8>] ? mnt_want_write+0x21/0x45 [ 261.564109] [<ffffffff8114d011>] ? __sb_start_write+0x10f/0x143 [ 261.564109] [<ffffffff811687e8>] ? mnt_want_write+0x21/0x45 [ 261.564109] [<ffffffff811687c0>] ? __mnt_want_write+0x48/0x4f [ 261.564109] [<ffffffff8116d3e6>] SyS_setxattr+0x6e/0xb0 [ 261.564109] [<ffffffff81529da9>] system_call_fastpath+0x16/0x1b [ 261.564109] Code: 48 89 f7 48 c7 c6 58 36 81 81 53 31 db e8 73 27 04 00 85 c0 75 28 bf 15 00 00 00 e8 8a a5 d9 ff 84 c0 75 05 83 cb ff eb 15 31 f6 <41> 80 7d 00 03 49 8b 7c 24 68 40 0f 94 c6 e8 e1 f9 ff ff 89 d8 [ 261.564109] RIP [<ffffffff812af272>] ima_inode_setxattr+0x3e/0x5a [ 261.564109] RSP <ffff880042be3d50> [ 261.564109] CR2: 0000000000000000 [ 261.599998] ---[ end trace 39a89a3fc267e652 ]---
--- security/integrity/ima/ima_appraise.c | 2 ++ security/integrity/integrity.h | 1 + 2 files changed, 3 insertions(+)
security/integrity/ima/ima_appraise.c +2 -0
@@ -378,6 +378,8 @@ int ima_inode_setxattr(struct dentry *de result =ima_protect_xattr (dentry, xattr_name, xattr_value, xattr_value_len);if (result ==1 ) { +if (!xattr_value_len || (xvalue->type >=IMA_XATTR_LAST )) +return -EINVAL ;ima_reset_appraise_flags (dentry->d_inode, (xvalue->type ==EVM_IMA_XATTR_DIGSIG ) ?1 :0 ); result =0 ;
security/integrity/integrity.h +1 -0
@@ -61,6 +61,7 @@ enum evm_ima_xattr_type {EVM_XATTR_HMAC ,EVM_IMA_XATTR_DIGSIG ,IMA_XATTR_DIGEST_NG , +IMA_XATTR_LAST }; struct evm_ima_xattr_data {
Greg Kroah-Hartman
maintainerPATCH 240/319 sh: fix sh770x SCIF memory regions
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andriy Skulysh <[email protected]>
commit 5417421b270229bfce0795ccc99a4b481e4954ca upstream.
Resources scif1_resources & scif2_resources overlap. Actual SCIF region size is 0x10.
This is regression from commit d850acf975be ("sh: Declare SCIF register base and IRQ as resources")
--- arch/sh/kernel/cpu/sh3/setup-sh770x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/sh/kernel/cpu/sh3/setup-sh770x.c +3 -3
@@ -118,7 +118,7 @@ static struct plat_sci_port scif0_platfo };static struct resource scif0_resources[] = { -DEFINE_RES_MEM (0xfffffe80 ,0x100 ), +DEFINE_RES_MEM (0xfffffe80 ,0x10 ),DEFINE_RES_IRQ (evt2irq (0x4e0 )), };
@@ -143,7 +143,7 @@ static struct plat_sci_port scif1_platfo };static struct resource scif1_resources[] = { -DEFINE_RES_MEM (0xa4000150 ,0x100 ), +DEFINE_RES_MEM (0xa4000150 ,0x10 ),DEFINE_RES_IRQ (evt2irq (0x900 )), };
@@ -169,7 +169,7 @@ static struct plat_sci_port scif2_platfo };static struct resource scif2_resources[] = { -DEFINE_RES_MEM (0xa4000140 ,0x100 ), +DEFINE_RES_MEM (0xa4000140 ,0x10 ),DEFINE_RES_IRQ (evt2irq (0x880 )), };
Greg Kroah-Hartman
maintainerPATCH 241/319 mm: free compound page with correct order
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Zhao <[email protected]>
commit 5ddacbe92b806cd5b4f8f154e8e46ac267fff55c upstream.
Compound page should be freed by put_page() or free_pages() with correct order. Not doing so will cause tail pages leaked.
The compound order can be obtained by compound_order() or use HPAGE_PMD_ORDER in our case. Some people would argue the latter is faster but I prefer the former which is more general.
This bug was observed not just on our servers (the worst case we saw is 11G leaked on a 48G machine) but also on our workstations running Ubuntu based distro.
$ cat /proc/vmstat | grep thp_zero_page_alloc thp_zero_page_alloc 55 thp_zero_page_alloc_failed 0
This means there is (thp_zero_page_alloc - 1) * (2M - 4K) memory leaked.
--- mm/huge_memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/huge_memory.c +2 -2
@@ -200,7 +200,7 @@ retry:preempt_disable ();if (cmpxchg (&huge_zero_page,NULL , zero_page)) {preempt_enable (); -__free_page (zero_page); +__free_pages (zero_page,compound_order (zero_page)); goto retry; }
@@ -232,7 +232,7 @@ static unsigned long shrink_huge_zero_paif (atomic_cmpxchg (&huge_zero_refcount,1 ,0 ) ==1 ) {struct page *zero_page =xchg (&huge_zero_page,NULL );BUG_ON (zero_page ==NULL ); -__free_page (zero_page); +__free_pages (zero_page,compound_order (zero_page));return HPAGE_PMD_NR ; }
Greg Kroah-Hartman
maintainerPATCH 242/319 cgroup/kmemleak: add kmemleak_free() for cgroup deallocations.
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Nan <[email protected]>
commit 401507d67d5c2854f5a88b3f93f64fc6f267bca5 upstream.
Commit ff7ee93f4715 ("cgroup/kmemleak: Annotate alloc_page() for cgroup allocations") introduces kmemleak_alloc() for alloc_page_cgroup(), but corresponding kmemleak_free() is missing, which makes kmemleak be wrongly disabled after memory offlining. Log is pasted at the end of this commit message.
This patch add kmemleak_free() into free_page_cgroup(). During page offlining, this patch removes corresponding entries in kmemleak rbtree. After that, the freed memory can be allocated again by other subsystems without killing kmemleak.
bash # for x in 1 2 3 4; do echo offline > /sys/devices/system/memory/memory$x/state ; sleep 1; done ; dmesg | grep leak
Offlined Pages 32768
kmemleak: Cannot insert 0xffff880016969000 into the object search tree (overlaps existing)
CPU: 0 PID: 412 Comm: sleep Not tainted 3.17.0-rc5+ #86
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Call Trace:
dump_stack+0x46/0x58
create_object+0x266/0x2c0
kmemleak_alloc+0x26/0x50
kmem_cache_alloc+0xd3/0x160
__sigqueue_alloc+0x49/0xd0
__send_signal+0xcb/0x410
send_signal+0x45/0x90
__group_send_sig_info+0x13/0x20
do_notify_parent+0x1bb/0x260
do_exit+0x767/0xa40
do_group_exit+0x44/0xa0
SyS_exit_group+0x17/0x20
system_call_fastpath+0x16/0x1b kmemleak: Kernel memory leak detector disabled
kmemleak: Object 0xffff880016900000 (size 524288):
kmemleak: comm "swapper/0", pid 0, jiffies 4294667296
kmemleak: min_count = 0
kmemleak: count = 0
kmemleak: flags = 0x1
kmemleak: checksum = 0
kmemleak: backtrace:
log_early+0x63/0x77
kmemleak_alloc+0x4b/0x50
init_section_page_cgroup+0x7f/0xf5
page_cgroup_init+0xc5/0xd0
start_kernel+0x333/0x408
x86_64_start_reservations+0x2a/0x2c
x86_64_start_kernel+0xf5/0xfc--- mm/page_cgroup.c | 1 + 1 file changed, 1 insertion(+)
mm/page_cgroup.c +1 -0
@@ -171,6 +171,7 @@ static void free_page_cgroup(void *addr)sizeof (struct page_cgroup ) *PAGES_PER_SECTION ;BUG_ON (PageReserved (page)); +kmemleak_free (addr);free_pages_exact (addr, table_size); } }
Greg Kroah-Hartman
maintainerPATCH 243/319 mm: page-writeback: inline account_page_dirtied() into single caller
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit 3a3c02ecf7f2852f122d6d16fb9b3d9cb0c6f201 upstream.
A follow-up patch would have changed the call signature. To save the trouble, just fold it instead.
--- include/linux/mm.h | 1 - mm/page-writeback.c | 23 ++++------------------- 2 files changed, 4 insertions(+), 20 deletions(-)
include/linux/mm.h +0 -1
@@ -1233,7 +1233,6 @@ int __set_page_dirty_no_writeback(structint redirty_page_for_writepage (struct writeback_control *wbc,struct page *page);void account_page_dirtied (struct page *page,struct address_space *mapping); -void account_page_writeback (struct page *page);int set_page_dirty (struct page *page);int set_page_dirty_lock (struct page *page);int clear_page_dirty_for_io (struct page *page);
mm/page-writeback.c +4 -19
@@ -2116,23 +2116,6 @@ void account_page_dirtied(struct page *pEXPORT_SYMBOL (account_page_dirtied);/* -* Helper function for set_page_writeback family. -* -* The caller must hold mem_cgroup_begin/end_update_page_stat() lock -* while calling this function. -* See test_set_page_writeback for example. -* -* NOTE: Unlike account_page_dirtied this does not rely on being atomic -* wrt interrupts. -*/ -void account_page_writeback (struct page *page) -{ -mem_cgroup_inc_page_stat (page,MEM_CGROUP_STAT_WRITEBACK ); -inc_zone_page_state (page,NR_WRITEBACK ); -} -EXPORT_SYMBOL (account_page_writeback); - -/* * For address_spaces which do not use buffers. Just tag the page as dirty in * its radix tree. *
@@ -2410,8 +2393,10 @@ int __test_set_page_writeback(struct pag }else { ret =TestSetPageWriteback (page); } -if (!ret) -account_page_writeback (page); +if (!ret) { +mem_cgroup_inc_page_stat (page,MEM_CGROUP_STAT_WRITEBACK ); +inc_zone_page_state (page,NR_WRITEBACK ); + }mem_cgroup_end_update_page_stat (page, &locked, &memcg_flags);return ret;
Greg Kroah-Hartman
maintainerPATCH 244/319 mm: memcontrol: fix missed end-writeback page accounting
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit d7365e783edb858279be1d03f61bc8d5d3383d90 upstream.
Commit 0a31bc97c80c ("mm: memcontrol: rewrite uncharge API") changed page migration to uncharge the old page right away. The page is locked, unmapped, truncated, and off the LRU, but it could race with writeback ending, which then doesn't unaccount the page properly:
test_clear_page_writeback() migration
wait_on_page_writeback()
TestClearPageWriteback()
mem_cgroup_migrate()
clear PCG_USED
mem_cgroup_update_page_stat()
if (PageCgroupUsed(pc))
decrease memcg pages under writeback
release pc->mem_cgroup->move_lock
The per-page statistics interface is heavily optimized to avoid a function call and a lookup_page_cgroup() in the file unmap fast path, which means it doesn't verify whether a page is still charged before clearing PageWriteback() and it has to do it in the stat update later.
Rework it so that it looks up the page's memcg once at the beginning of the transaction and then uses it throughout. The charge will be verified before clearing PageWriteback() and migration can't uncharge the page as long as that is still set. The RCU lock will protect the memcg past uncharge.
As far as losing the optimization goes, the following test results are from a microbenchmark that maps, faults, and unmaps a 4GB sparse file three times in a nested fashion, so that there are two negative passes that don't account but still go through the new transaction overhead. There is no actual difference:
old: 33.195102545 seconds time elapsed ( +- 0.01% ) new: 33.199231369 seconds time elapsed ( +- 0.03% )
The time spent in page_remove_rmap()'s callees still adds up to the same, but the time spent in the function itself seems reduced:
# Children Self Command Shared Object Symbol old: 0.12% 0.11% filemapstress [kernel.kallsyms] [k] page_remove_rmap new: 0.12% 0.08% filemapstress [kernel.kallsyms] [k] page_remove_rmap
--- include/linux/memcontrol.h | 56 ++++++--------------- mm/memcontrol.c | 115 ++++++++++++++++++++++++--------------------- mm/page-writeback.c | 22 ++++---- mm/rmap.c | 20 +++---- 4 files changed, 100 insertions(+), 113 deletions(-)
include/linux/memcontrol.h +16 -40
@@ -139,48 +139,23 @@ static inline bool mem_cgroup_disabled(vreturn false; } -void __mem_cgroup_begin_update_page_stat (struct page *page,bool *locked, -unsigned long *flags); +struct mem_cgroup *mem_cgroup_begin_page_stat (struct page *page,bool *locked, +unsigned long *flags); +void mem_cgroup_end_page_stat (struct mem_cgroup *memcg,bool locked, +unsigned long flags); +void mem_cgroup_update_page_stat (struct mem_cgroup *memcg, +enum mem_cgroup_stat_index idx,int val); -extern atomic_t memcg_moving; - -static inline void mem_cgroup_begin_update_page_stat (struct page *page, -bool *locked,unsigned long *flags) -{ -if (mem_cgroup_disabled ()) -return ; -rcu_read_lock (); - *locked = false; -if (atomic_read (&memcg_moving)) -__mem_cgroup_begin_update_page_stat (page, locked, flags); -} - -void __mem_cgroup_end_update_page_stat (struct page *page, -unsigned long *flags); -static inline void mem_cgroup_end_update_page_stat (struct page *page, -bool *locked,unsigned long *flags) -{ -if (mem_cgroup_disabled ()) -return ; -if (*locked) -__mem_cgroup_end_update_page_stat (page, flags); -rcu_read_unlock (); -} - -void mem_cgroup_update_page_stat (struct page *page, -enum mem_cgroup_stat_index idx, -int val); - -static inline void mem_cgroup_inc_page_stat (struct page *page, +static inline void mem_cgroup_inc_page_stat (struct mem_cgroup *memcg,enum mem_cgroup_stat_index idx) { -mem_cgroup_update_page_stat (page, idx,1 ); +mem_cgroup_update_page_stat (memcg, idx,1 ); } -static inline void mem_cgroup_dec_page_stat (struct page *page, +static inline void mem_cgroup_dec_page_stat (struct mem_cgroup *memcg,enum mem_cgroup_stat_index idx) { -mem_cgroup_update_page_stat (page, idx,-1 ); +mem_cgroup_update_page_stat (memcg, idx,-1 ); } unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
@@ -315,13 +290,14 @@ mem_cgroup_print_oom_info(struct mem_cgr { } -static inline void mem_cgroup_begin_update_page_stat (struct page *page, +static inline struct mem_cgroup *mem_cgroup_begin_page_stat (struct page *page,bool *locked,unsigned long *flags) { +return NULL ; } -static inline void mem_cgroup_end_update_page_stat (struct page *page, -bool *locked,unsigned long *flags) +static inline void mem_cgroup_end_page_stat (struct mem_cgroup *memcg, +bool locked,unsigned long flags) { }
@@ -343,12 +319,12 @@ static inline bool mem_cgroup_oom_synchrreturn false; } -static inline void mem_cgroup_inc_page_stat (struct page *page, +static inline void mem_cgroup_inc_page_stat (struct mem_cgroup *memcg,enum mem_cgroup_stat_index idx) { } -static inline void mem_cgroup_dec_page_stat (struct page *page, +static inline void mem_cgroup_dec_page_stat (struct mem_cgroup *memcg,enum mem_cgroup_stat_index idx) { }
mm/memcontrol.c +62 -53
161 lines not on this page · raw message
mm/page-writeback.c +12 -10
@@ -2327,11 +2327,12 @@ EXPORT_SYMBOL(clear_page_dirty_for_io);int test_clear_page_writeback (struct page *page) {struct address_space *mapping =page_mapping (page); -int ret; -bool locked;unsigned long memcg_flags; +struct mem_cgroup *memcg; +bool locked; +int ret; -mem_cgroup_begin_update_page_stat (page, &locked, &memcg_flags); + memcg =mem_cgroup_begin_page_stat (page, &locked, &memcg_flags);if (mapping) {struct backing_dev_info *bdi = mapping->backing_dev_info;unsigned long flags;
@@ -2352,22 +2353,23 @@ int test_clear_page_writeback(struct pag ret =TestClearPageWriteback (page); }if (ret) { -mem_cgroup_dec_page_stat (page,MEM_CGROUP_STAT_WRITEBACK ); +mem_cgroup_dec_page_stat (memcg,MEM_CGROUP_STAT_WRITEBACK );dec_zone_page_state (page,NR_WRITEBACK );inc_zone_page_state (page,NR_WRITTEN ); } -mem_cgroup_end_update_page_stat (page, &locked, &memcg_flags); +mem_cgroup_end_page_stat (memcg, locked, memcg_flags);return ret; }int __test_set_page_writeback (struct page *page,bool keep_write) {struct address_space *mapping =page_mapping (page); -int ret; -bool locked;unsigned long memcg_flags; +struct mem_cgroup *memcg; +bool locked; +int ret; -mem_cgroup_begin_update_page_stat (page, &locked, &memcg_flags); + memcg =mem_cgroup_begin_page_stat (page, &locked, &memcg_flags);if (mapping) {struct backing_dev_info *bdi = mapping->backing_dev_info;unsigned long flags;
@@ -2394,10 +2396,10 @@ int __test_set_page_writeback(struct pag ret =TestSetPageWriteback (page); }if (!ret) { -mem_cgroup_inc_page_stat (page,MEM_CGROUP_STAT_WRITEBACK ); +mem_cgroup_inc_page_stat (memcg,MEM_CGROUP_STAT_WRITEBACK );inc_zone_page_state (page,NR_WRITEBACK ); } -mem_cgroup_end_update_page_stat (page, &locked, &memcg_flags); +mem_cgroup_end_page_stat (memcg, locked, memcg_flags);return ret; }
mm/rmap.c +10 -10
@@ -1042,15 +1042,16 @@ void page_add_new_anon_rmap(struct page*/ void page_add_file_rmap (struct page *page) { -bool locked; +struct mem_cgroup *memcg;unsigned long flags; +bool locked; -mem_cgroup_begin_update_page_stat (page, &locked, &flags); + memcg =mem_cgroup_begin_page_stat (page, &locked, &flags);if (atomic_inc_and_test (&page->_mapcount)) {__inc_zone_page_state (page,NR_FILE_MAPPED ); -mem_cgroup_inc_page_stat (page,MEM_CGROUP_STAT_FILE_MAPPED ); +mem_cgroup_inc_page_stat (memcg,MEM_CGROUP_STAT_FILE_MAPPED ); } -mem_cgroup_end_update_page_stat (page, &locked, &flags); +mem_cgroup_end_page_stat (memcg, locked, flags); }/**
@@ -1061,9 +1062,10 @@ void page_add_file_rmap(struct page *pag*/ void page_remove_rmap (struct page *page) { +struct mem_cgroup *uninitialized_var (memcg );bool anon =PageAnon (page); -bool locked;unsigned long flags; +bool locked;/* * The anon case has no mem_cgroup page_stat to update; but may
@@ -1071,7 +1073,7 @@ void page_remove_rmap(struct page *page)* we hold the lock against page_stat move: so avoid it on anon. */ if (!anon) -mem_cgroup_begin_update_page_stat (page, &locked, &flags); + memcg =mem_cgroup_begin_page_stat (page, &locked, &flags);/* page still mapped by someone else? */ if (!atomic_add_negative (-1 , &page->_mapcount))
@@ -1096,8 +1098,7 @@ void page_remove_rmap(struct page *page) -hpage_nr_pages(page)); }else {__dec_zone_page_state (page,NR_FILE_MAPPED ); -mem_cgroup_dec_page_stat (page,MEM_CGROUP_STAT_FILE_MAPPED ); -mem_cgroup_end_update_page_stat (page, &locked, &flags); +mem_cgroup_dec_page_stat (memcg,MEM_CGROUP_STAT_FILE_MAPPED ); }if (unlikely (PageMlocked (page)))clear_page_mlock (page);
@@ -1110,10 +1111,9 @@ void page_remove_rmap(struct page *page)* Leaving it set also helps swapoff to reinstate ptes * faster for those pages still in swapcache. */ -return ; out:if (!anon) -mem_cgroup_end_update_page_stat (page, &locked, &flags); +mem_cgroup_end_page_stat (memcg, locked, flags); }/*
Greg Kroah-Hartman
maintainerPATCH 245/319 lib/bitmap.c: fix undefined shift in __bitmap_shift_{left|right}()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit ea5d05b34aca25c066e0699512d0ffbd8ee6ac3e upstream.
If __bitmap_shift_left() or __bitmap_shift_right() are asked to shift by a multiple of BITS_PER_LONG, they will try to shift a long value by BITS_PER_LONG bits which is undefined. Change the functions to avoid the undefined shift.
Coverity id: 1192175
Coverity id: 1192174
--- lib/bitmap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
lib/bitmap.c +6 -2
@@ -131,7 +131,9 @@ void __bitmap_shift_right(unsigned long lower = src[off + k];if (left && off + k == lim -1 ) lower &= mask; - dst[k] = upper << (BITS_PER_LONG - rem) | lower >> rem; + dst[k] = lower >> rem; +if (rem) + dst[k] |= upper << (BITS_PER_LONG - rem);if (left && k == lim -1 ) dst[k] &= mask; }
@@ -172,7 +174,9 @@ void __bitmap_shift_left(unsigned long * upper = src[k];if (left && k == lim -1 ) upper &= (1UL << left) -1 ; - dst[k + off] = lower >> (BITS_PER_LONG - rem) | upper << rem; + dst[k + off] = upper << rem; +if (rem) + dst[k + off] |= lower >> (BITS_PER_LONG - rem);if (left && k + off == lim -1 ) dst[k + off] &= (1UL << left) -1 ; }
Greg Kroah-Hartman
maintainerPATCH 246/319 mm/balloon_compaction: fix deflation when compaction is disabled
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Khlebnikov <[email protected]>
commit 4d88e6f7d5ffc84e6094a47925870f4a130555c2 upstream.
If CONFIG_BALLOON_COMPACTION=n balloon_page_insert() does not link pages with balloon and doesn't set PagePrivate flag, as a result balloon_page_dequeue() cannot get any pages because it thinks that all of them are isolated. Without balloon compaction nobody can isolate ballooned pages. It's safe to remove this check.
--- mm/balloon_compaction.c | 2 ++ 1 file changed, 2 insertions(+)
mm/balloon_compaction.c +2 -0
@@ -93,11 +93,13 @@ struct page *balloon_page_dequeue(struct* to be released by the balloon driver. */ if (trylock_page (page)) { +#ifdef CONFIG_BALLOON_COMPACTION if (!PagePrivate (page)) {/* raced with isolation */ unlock_page (page);continue ; } +#endif spin_lock_irqsave (&b_dev_info->pages_lock, flags);balloon_page_delete (page);spin_unlock_irqrestore (&b_dev_info->pages_lock, flags);
Greg Kroah-Hartman
maintainerPATCH 247/319 xhci: no switching back on non-ULT Haswell
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit b45abacde3d551c6696c6738bef4a1805d0bf27a upstream.
The switch back is limited to ULT even on HP. The contrary finding arose by bad luck in BIOS versions for testing. This fixes spontaneous resume from S3 on some HP laptops.
--- drivers/usb/host/xhci-pci.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/usb/host/xhci-pci.c +0 -14
@@ -126,20 +126,6 @@ static void xhci_pci_quirks(struct devic xhci->quirks |=XHCI_AVOID_BEI ; }if (pdev->vendor ==PCI_VENDOR_ID_INTEL && - (pdev->device ==PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI || - pdev->device ==PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI )) { -/* Workaround for occasional spurious wakeups from S5 (or -* any other sleep) on Haswell machines with LPT and LPT-LP -* with the new Intel BIOS -*/ -/* Limit the quirk to only known vendors, as this triggers -* yet another BIOS bug on some other machines -* https://bugzilla.kernel.org/show_bug.cgi?id=66171 -*/ -if (pdev->subsystem_vendor ==PCI_VENDOR_ID_HP ) - xhci->quirks |=XHCI_SPURIOUS_WAKEUP ; - } -if (pdev->vendor ==PCI_VENDOR_ID_INTEL && pdev->device ==PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI ) { xhci->quirks |=XHCI_SPURIOUS_REBOOT ; }
Greg Kroah-Hartman
maintainerPATCH 248/319 xhci: Disable streams on Asmedia 1042 xhci controllers
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 2391eacbd00b706ff4902db7dbee21e33b6f1850 upstream.
Streams seem to be broken on the Asmedia 1042. An uas capable Seagate disk which is known to work fine with other controllers causes the system to freeze when connected over usb-3 with this controller, where as it works fine with uas in usb-2 ports, indicating a problem with streams.
This is a bit bigger hammer then I would like to use for this, but for now it will have to make do. I've ordered a pci-e usb controller card with an Asmedia 1042, once that arrives I'll try to get streams to work (with a quirk flag if necessary) and then we can re-enable them. For now this at least makes uas capable disk enclosures work again by forcing fallback to the usb-storage driver.
--- drivers/usb/host/xhci-pci.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/host/xhci-pci.c +4 -0
@@ -146,6 +146,10 @@ static void xhci_pci_quirks(struct devic pdev->device == 0x3432) xhci->quirks |=XHCI_BROKEN_STREAMS ; +if (pdev->vendor ==PCI_VENDOR_ID_ASMEDIA && + pdev->device ==0x1042 ) + xhci->quirks |=XHCI_BROKEN_STREAMS ; +if (xhci->quirks &XHCI_RESET_ON_RESUME )xhci_dbg_trace (xhci, trace_xhci_dbg_quirks,"QUIRK: Resetting on resume" );
Greg Kroah-Hartman
maintainerPATCH 249/319 scsi: Fix error handling in SCSI_IOCTL_SEND_COMMAND
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 84ce0f0e94ac97217398b3b69c21c7a62ebeed05 upstream.
When sg_scsi_ioctl() fails to prepare request to submit in blk_rq_map_kern() we jump to a label where we just end up copying (luckily zeroed-out) kernel buffer to userspace instead of reporting error. Fix the problem by jumping to the right label.
CC: Jens Axboe <[email protected]>
CC: [email protected]
Coverity-id: 1226871
Fixed up the, now unused, out label.
--- block/scsi_ioctl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
block/scsi_ioctl.c +1 -2
@@ -509,7 +509,7 @@ int sg_scsi_ioctl(struct request_queue *if (bytes &&blk_rq_map_kern (q, rq, buffer, bytes, __GFP_WAIT)) { err =DRIVER_ERROR <<24 ; - goto out; + goto error; }memset (sense,0 ,sizeof (sense));
@@ -518,7 +518,6 @@ int sg_scsi_ioctl(struct request_queue *blk_execute_rq (q, disk, rq,0 ); -out: err = rq->errors &0xff ;/* only 8 bit SCSI status */ if (err) {if (rq->sense_len && rq->sense) {
Greg Kroah-Hartman
maintainerPATCH 250/319 lib/scatterlist: fix memory leak with scsi-mq
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Battersby <[email protected]>
commit c21e59d8dc04b2107bdb4ff0f412a9b7ae3349f3 upstream.
Fix a memory leak with scsi-mq triggered by commands with large data transfer length.
--- lib/scatterlist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/scatterlist.c +3 -3
@@ -203,10 +203,10 @@ void __sg_free_table(struct sg_table *ta } table->orig_nents -= sg_size; -if (!skip_first_chunk) { -free_fn (sgl, alloc_size); +if (skip_first_chunk) skip_first_chunk = false; - } +else +free_fn (sgl, alloc_size); sgl = next; }
Greg Kroah-Hartman
maintainerPATCH 251/319 scsi: set REQ_QUEUE for the blk-mq case
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
commit b1dd2aac4cc0892b82ec60232ed37e3b0af776cc upstream.
To generate the right SPI tag messages we need to properly set QUEUE_FLAG_QUEUED in the request_queue and mirror it to the request.
--- drivers/scsi/scsi_lib.c | 5 +++++ include/scsi/scsi_tcq.h | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/scsi/scsi_lib.c +5 -0
@@ -1887,6 +1887,11 @@ static int scsi_queue_rq(struct blk_mq_h req->cmd_flags |=REQ_DONTPREP ; } +if (blk_queue_tagged (q)) + req->cmd_flags |=REQ_QUEUED ; +else + req->cmd_flags &= ~REQ_QUEUED ; +scsi_init_cmd_errh (cmd); cmd->scsi_done = scsi_mq_done;
include/scsi/scsi_tcq.h +4 -4
@@ -67,8 +67,9 @@ static inline void scsi_activate_tcq(strif (!sdev->tagged_supported)return ; -if (!shost_use_blk_mq (sdev->host) && - !blk_queue_tagged (sdev->request_queue)) +if (shost_use_blk_mq (sdev->host)) +queue_flag_set_unlocked (QUEUE_FLAG_QUEUED , sdev->request_queue); +else if (!blk_queue_tagged (sdev->request_queue))blk_queue_init_tags (sdev->request_queue, depth, sdev->host->bqt);
@@ -81,8 +82,7 @@ static inline void scsi_activate_tcq(str**/ static inline void scsi_deactivate_tcq (struct scsi_device *sdev,int depth) { -if (!shost_use_blk_mq (sdev->host) && -blk_queue_tagged (sdev->request_queue)) +if (blk_queue_tagged (sdev->request_queue))blk_queue_free_tags (sdev->request_queue);scsi_adjust_queue_depth (sdev,0 , depth); }
Greg Kroah-Hartman
maintainerPATCH 252/319 i82860_edac: Report CE events properly
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Baron <[email protected]>
commit ab0543de6ff0877474f57a5aafbb51a61e88676f upstream.
Fix CE event being reported as HW_EVENT_ERR_UNCORRECTED.
--- drivers/edac/i82860_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/i82860_edac.c +1 -1
@@ -124,7 +124,7 @@ static int i82860_process_error_info(str dimm->location[0 ], dimm->location[1 ],-1 , "i82860 UE", ""); else - edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, + edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, info->eap, 0, info->derrsyn, dimm->location[0], dimm->location[1], -1, "i82860 CE", "");
Greg Kroah-Hartman
maintainerPATCH 253/319 i3200_edac: Report CE events properly
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Baron <[email protected]>
commit 8a3f075d6c9b3612b4a5fb2af8db82b38b20caf0 upstream.
Fix CE event being reported as HW_EVENT_ERR_UNCORRECTED.
--- drivers/edac/i3200_edac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/edac/i3200_edac.c +2 -2
@@ -242,11 +242,11 @@ static void i3200_process_error_info(str-1 ,-1 , "i3000 UE", ""); }else if (log &I3200_ECCERRLOG_CE ) { -edac_mc_handle_error (HW_EVENT_ERR_UNCORRECTED , mci,1 , +edac_mc_handle_error (HW_EVENT_ERR_CORRECTED , mci,1 ,0 ,0 ,eccerrlog_syndrome (log),eccerrlog_row (channel, log),-1 ,-1 , -"i3000 UE" ,"" ); +"i3000 CE" ,"" ); } } }
Greg Kroah-Hartman
maintainerPATCH 254/319 e7xxx_edac: Report CE events properly
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Baron <[email protected]>
commit 8030122a9ccf939186f8db96c318dbb99b5463f6 upstream.
Fix CE event being reported as HW_EVENT_ERR_UNCORRECTED.
--- drivers/edac/e7xxx_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/e7xxx_edac.c +1 -1
@@ -226,7 +226,7 @@ static void process_ce(struct mem_ctl_instatic void process_ce_no_info (struct mem_ctl_info *mci) {edac_dbg (3 ,"\n" ); -edac_mc_handle_error (HW_EVENT_ERR_UNCORRECTED , mci,1 ,0 ,0 ,0 ,-1 ,-1 ,-1 , +edac_mc_handle_error (HW_EVENT_ERR_CORRECTED , mci,1 ,0 ,0 ,0 ,-1 ,-1 ,-1 ,"e7xxx CE log register overflow" ,"" ); }
Greg Kroah-Hartman
maintainerPATCH 255/319 cpc925_edac: Report UE events properly
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Baron <[email protected]>
commit fa19ac4b92bc2b5024af3e868f41f81fa738567a upstream.
Fix UE event being reported as HW_EVENT_ERR_CORRECTED.
--- drivers/edac/cpc925_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/cpc925_edac.c +1 -1
@@ -562,7 +562,7 @@ static void cpc925_mc_check(struct mem_cif (apiexcp &UECC_EXCP_DETECTED ) {cpc925_mc_printk (mci,KERN_INFO ,"DRAM UECC Fault\n" ); -edac_mc_handle_error (HW_EVENT_ERR_CORRECTED , mci,1 , +edac_mc_handle_error (HW_EVENT_ERR_UNCORRECTED , mci,1 , pfn, offset,0 , csrow,-1 ,-1 , mci->ctl_name,"" );
Greg Kroah-Hartman
maintainerPATCH 256/319 nfsd4: fix response size estimation for OP_SEQUENCE
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: "J. Bruce Fields" <[email protected]>
commit d1d84c9626bb3a519863b3ffc40d347166f9fb83 upstream.
We added this new estimator function but forgot to hook it up. The effect is that NFSv4.1 (and greater) won't do zero-copy reads.
The estimate was also wrong by 8 bytes.
--- fs/nfsd/nfs4proc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfsd/nfs4proc.c +3 -1
@@ -1546,7 +1546,8 @@ static inline u32 nfsd4_rename_rsize(strstatic inline u32 nfsd4_sequence_rsize (struct svc_rqst *rqstp,struct nfsd4_op *op) { -return NFS4_MAX_SESSIONID_LEN +20 ; +return (op_encode_hdr_size + +XDR_QUADLEN (NFS4_MAX_SESSIONID_LEN ) +5 ) *sizeof (__be32); }static inline u32 nfsd4_setattr_rsize (struct svc_rqst *rqstp,struct nfsd4_op *op)
@@ -1850,6 +1851,7 @@ static struct nfsd4_operation nfsd4_ops[ .op_func = (nfsd4op_func)nfsd4_sequence, .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP, .op_name = "OP_SEQUENCE", + .op_rsize_bop = (nfsd4op_rsize)nfsd4_sequence_rsize, }, [OP_DESTROY_CLIENTID] = { .op_func = (nfsd4op_func)nfsd4_destroy_clientid,
Greg Kroah-Hartman
maintainerPATCH 257/319 nfsd4: fix crash on unknown operation number
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: "J. Bruce Fields" <[email protected]>
commit 51904b08072a8bf2b9ed74d1bd7a5300a614471d upstream.
Unknown operation numbers are caught in nfsd4_decode_compound() which sets op->opnum to OP_ILLEGAL and op->status to nfserr_op_illegal. The error causes the main loop in nfsd4_proc_compound() to skip most processing. But nfsd4_proc_compound also peeks ahead at the next operation in one case and doesn't take similar precautions there.
--- fs/nfsd/nfs4proc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/nfs4proc.c +2 -1
@@ -1229,7 +1229,8 @@ static bool need_wrongsec_check(struct s*/ if (argp->opcnt == resp->opcnt)return false; - +if (next->opnum ==OP_ILLEGAL ) +return false; nextd =OPDESC (next);/* * Rest of 2.6.3.1.1: certain operations will return WRONGSEC
Greg Kroah-Hartman
maintainerPATCH 258/319 zap_pte_range: update addr when forcing flush after TLB batching faiure
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit ce9ec37bddb633404a0c23e1acb181a264e7f7f2 upstream.
When unmapping a range of pages in zap_pte_range, the page being unmapped is added to an mmu_gather_batch structure for asynchronous freeing. If we run out of space in the batch structure before the range has been completely unmapped, then we break out of the loop, force a TLB flush and free the pages that we have batched so far. If there are further pages to unmap, then we resume the loop where we left off.
Unfortunately, we forget to update addr when we break out of the loop, which causes us to truncate the range being invalidated as the end address is exclusive. When we re-enter the loop at the same address, the page has already been freed and the pte_present test will fail, meaning that we do not reconsider the address for invalidation.
This patch fixes the problem by incrementing addr by the PAGE_SIZE before breaking out of the loop on batch failure.
--- mm/memory.c | 1 + 1 file changed, 1 insertion(+)
mm/memory.c +1 -0
@@ -1147,6 +1147,7 @@ again:print_bad_pte (vma, addr, ptent, page);if (unlikely (!__tlb_remove_page (tlb, page))) { force_flush =1 ; + addr +=PAGE_SIZE ;break ; }continue ;
Greg Kroah-Hartman
maintainerPATCH 259/319 iwlwifi: mvm: BT Coex - update the MPLUT Boost register value
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
commit d14b28fd2c61af0bf310230472e342864d799c98 upstream.
--- drivers/net/wireless/iwlwifi/mvm/coex.c | 4 ++-- drivers/net/wireless/iwlwifi/mvm/coex_legacy.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/iwlwifi/mvm/coex.c +2 -2
@@ -301,8 +301,8 @@ static const __le64 iwl_ci_mask[][3] = { };static const __le32 iwl_bt_mprio_lut[BT_COEX_MULTI_PRIO_LUT_SIZE ] = { -cpu_to_le32 (0x28412201 ), -cpu_to_le32 (0x11118451 ), +cpu_to_le32 (0x2e402280 ), +cpu_to_le32 (0x7711a751 ), };struct corunning_block_luts {
drivers/net/wireless/iwlwifi/mvm/coex_legacy.c +2 -2
@@ -289,8 +289,8 @@ static const __le64 iwl_ci_mask[][3] = { };static const __le32 iwl_bt_mprio_lut[BT_COEX_MULTI_PRIO_LUT_SIZE ] = { -cpu_to_le32 (0x28412201 ), -cpu_to_le32 (0x11118451 ), +cpu_to_le32 (0x2e402280 ), +cpu_to_le32 (0x7711a751 ), };struct corunning_block_luts {
Greg Kroah-Hartman
maintainerPATCH 260/319 iwlwifi: configure the LTR
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
commit 9180ac50716a097a407c6d7e7e4589754a922260 upstream.
The LTR is the handshake between the device and the root complex about the latency allowed when the bus exits power save. This configuration was missing and this led to high latency in the link power up. The end user could experience high latency in the network because of this.
--- drivers/net/wireless/iwlwifi/iwl-trans.h | 2 + drivers/net/wireless/iwlwifi/mvm/fw-api-power.h | 35 +++++++++++++++++++++++- drivers/net/wireless/iwlwifi/mvm/fw-api.h | 1 drivers/net/wireless/iwlwifi/mvm/fw.c | 9 ++++++ drivers/net/wireless/iwlwifi/mvm/ops.c | 1 drivers/net/wireless/iwlwifi/pcie/trans.c | 16 ++++++---- 6 files changed, 56 insertions(+), 8 deletions(-)
drivers/net/wireless/iwlwifi/iwl-trans.h +2 -0
@@ -548,6 +548,7 @@ enum iwl_trans_state {* Set during transport allocation. * @hw_id_str: a string with info about HW ID. Set during transport allocation. * @pm_support: set to true in start_hw if link pm is supported +* @ltr_enabled: set to true if the LTR is enabled * @dev_cmd_pool: pool for Tx cmd allocation - for internal use only. * The user should use iwl_trans_{alloc,free}_tx_cmd. * @dev_cmd_headroom: room needed for the transport's private use before the
@@ -574,6 +575,7 @@ struct iwl_trans {u8 rx_mpdu_cmd, rx_mpdu_cmd_hdr_size;bool pm_support; +bool ltr_enabled;/* The following fields are internal only */ struct kmem_cache *dev_cmd_pool;
drivers/net/wireless/iwlwifi/mvm/fw-api-power.h +34 -1
@@ -66,13 +66,46 @@/* Power Management Commands, Responses, Notifications */ +/** +* enum iwl_ltr_config_flags - masks for LTR config command flags +* @LTR_CFG_FLAG_FEATURE_ENABLE: Feature operational status +* @LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS: allow LTR change on shadow +* memory access +* @LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH: allow LTR msg send on ANY LTR +* reg change +* @LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3: allow LTR msg send on transition from +* D0 to D3 +* @LTR_CFG_FLAG_SW_SET_SHORT: fixed static short LTR register +* @LTR_CFG_FLAG_SW_SET_LONG: fixed static short LONG register +* @LTR_CFG_FLAG_DENIE_C10_ON_PD: allow going into C10 on PD +*/ +enum iwl_ltr_config_flags { +LTR_CFG_FLAG_FEATURE_ENABLE =BIT (0 ), +LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS =BIT (1 ), +LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH =BIT (2 ), +LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3 =BIT (3 ), +LTR_CFG_FLAG_SW_SET_SHORT =BIT (4 ), +LTR_CFG_FLAG_SW_SET_LONG =BIT (5 ), +LTR_CFG_FLAG_DENIE_C10_ON_PD =BIT (6 ), +}; + +/** +* struct iwl_ltr_config_cmd - configures the LTR +* @flags: See %enum iwl_ltr_config_flags +*/ +struct iwl_ltr_config_cmd { +__le32 flags; +__le32 static_long; +__le32 static_short; +} __packed; +/* Radio LP RX Energy Threshold measured in dBm */ #define POWER_LPRX_RSSI_THRESHOLD 75#define POWER_LPRX_RSSI_THRESHOLD_MAX 94#define POWER_LPRX_RSSI_THRESHOLD_MIN 30/** -* enum iwl_scan_flags - masks for power table command flags +* enum iwl_power_flags - masks for power table command flags * @POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off * receiver and transmitter. '0' - does not allow. * @POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK: '0' Driver disables power management,
drivers/net/wireless/iwlwifi/mvm/fw-api.h +1 -0
@@ -148,6 +148,7 @@ enum {/* Power - legacy power table command */ POWER_TABLE_CMD =0x77 ,PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION =0x78 , +LTR_CONFIG =0xee ,/* Thermal Throttling*/ REPLY_THERMAL_MNG_BACKOFF = 0x7e,
drivers/net/wireless/iwlwifi/mvm/fw.c +9 -0
@@ -475,6 +475,15 @@ int iwl_mvm_up(struct iwl_mvm *mvm)/* Initialize tx backoffs to the minimal possible */ iwl_mvm_tt_tx_backoff (mvm,0 ); +if (mvm->trans->ltr_enabled) { +struct iwl_ltr_config_cmd cmd = { + .flags =cpu_to_le32 (LTR_CFG_FLAG_FEATURE_ENABLE ), + }; + +WARN_ON (iwl_mvm_send_cmd_pdu (mvm,LTR_CONFIG ,0 , +sizeof (cmd), &cmd)); + } + ret =iwl_mvm_power_update_device (mvm);if (ret) goto error;
drivers/net/wireless/iwlwifi/mvm/ops.c +1 -0
@@ -332,6 +332,7 @@ static const char *const iwl_mvm_cmd_strCMD (REPLY_BEACON_FILTERING_CMD ),CMD (REPLY_THERMAL_MNG_BACKOFF ),CMD (MAC_PM_POWER_TABLE ), +CMD (LTR_CONFIG ),CMD (BT_COEX_CI ),CMD (BT_COEX_UPDATE_SW_BOOST ), CMD(BT_COEX_UPDATE_CORUN_LUT),
drivers/net/wireless/iwlwifi/pcie/trans.c +9 -7
@@ -172,6 +172,7 @@ static void iwl_pcie_apm_config(struct i {struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans);u16 lctl; +u16 cap;/* * HW bug W/A for instability in PCIe bus L0S->L1 transition.
@@ -182,16 +183,17 @@ static void iwl_pcie_apm_config(struct i* power savings, even without L1. */ pcie_capability_read_word (trans_pcie->pci_dev,PCI_EXP_LNKCTL , &lctl); -if (lctl &PCI_EXP_LNKCTL_ASPM_L1 ) { -/* L1-ASPM enabled; disable(!) L0S */ +if (lctl &PCI_EXP_LNKCTL_ASPM_L1 )iwl_set_bit (trans,CSR_GIO_REG ,CSR_GIO_REG_VAL_L0S_ENABLED ); -dev_info (trans->dev,"L1 Enabled; Disabling L0S\n" ); - }else { -/* L1-ASPM disabled; enable(!) L0S */ +else iwl_clear_bit (trans,CSR_GIO_REG ,CSR_GIO_REG_VAL_L0S_ENABLED ); -dev_info (trans->dev,"L1 Disabled; Enabling L0S\n" ); - } trans->pm_support = !(lctl &PCI_EXP_LNKCTL_ASPM_L0S ); + +pcie_capability_read_word (trans_pcie->pci_dev,PCI_EXP_DEVCTL2 , &cap); + trans->ltr_enabled = cap &PCI_EXP_DEVCTL2_LTR_EN ; +dev_info (trans->dev,"L1 %sabled - LTR %sabled\n" , + (lctl &PCI_EXP_LNKCTL_ASPM_L1 ) ?"En" :"Dis" , + trans->ltr_enabled ?"En" :"Dis" ); }/*
Greg Kroah-Hartman
maintainerPATCH 261/319 iwlwifi: dvm: drop non VO frames when flushing
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
commit a0855054e59b0c5b2b00237fdb5147f7bcc18efb upstream.
When mac80211 wants to ensure that a frame is sent, it calls the flush() callback. Until now, iwldvm implemented this by waiting that all the frames are sent (ACKed or timeout). In case of weak signal, this can take a significant amount of time, delaying the next connection (in case of roaming). Many users have reported that the flush would take too long leading to the following error messages to be printed:
iwlwifi 0000:03:00.0: fail to flush all tx fifo queues Q 2 iwlwifi 0000:03:00.0: Current SW read_ptr 161 write_ptr 201
iwl data: 00000000: 00 00 00 00 00 00 00 00 fe ff 01 00 00 00 00 00 [snip]
iwlwifi 0000:03:00.0: FH TRBs(0) = 0x00000000
[snip]
iwlwifi 0000:03:00.0: Q 0 is active and mapped to fifo 3 ra_tid 0x0000 [9,9] [snip]
Instead of waiting for these packets, simply drop them. This significantly improves the responsiveness of the network. Note that all the queues are flushed, but the VO one. This is not typically used by the applications and it likely contains management frames that are useful for connection or roaming.
This bug is tracked here:
https://bugzilla.kernel.org/show_bug.cgi?id=56581
But it is duplicated in distributions' trackers. A simple search in Ubuntu's database led to these bugs:
https://bugs.launchpad.net/ubuntu/+source/linux-firmware/+bug/1270808
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1305406
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1356236
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1360597
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1361809
Depends-on: 77be2c54c5bd ("mac80211: add vif to flush call")
--- drivers/net/wireless/iwlwifi/dvm/mac80211.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/net/wireless/iwlwifi/dvm/mac80211.c +13 -11
@@ -1095,6 +1095,7 @@ static void iwlagn_mac_flush(struct ieee u32 queues, bool drop) {struct iwl_priv *priv =IWL_MAC80211_GET_DVM (hw); +u32 scd_queues;mutex_lock (&priv->mutex);IWL_DEBUG_MAC80211 (priv,"enter\n" );
@@ -1108,18 +1109,19 @@ static void iwlagn_mac_flush(struct ieee goto done; } -/* -* mac80211 will not push any more frames for transmit -* until the flush is completed -*/ -if (drop) { -IWL_DEBUG_MAC80211 (priv,"send flush command\n" ); -if (iwlagn_txfifo_flush (priv,0 )) { -IWL_ERR (priv,"flush request fail\n" ); - goto done; - } + scd_queues =BIT (priv->cfg->base_params->num_of_queues) -1 ; + scd_queues &= ~(BIT (IWL_IPAN_CMD_QUEUE_NUM ) | +BIT (IWL_DEFAULT_CMD_QUEUE_NUM )); + +if (vif) + scd_queues &= ~BIT (vif->hw_queue[IEEE80211_AC_VO ]); + +IWL_DEBUG_TX_QUEUES (priv,"Flushing SCD queues: 0x%x\n" , scd_queues); +if (iwlagn_txfifo_flush (priv, scd_queues)) { +IWL_ERR (priv,"flush request fail\n" ); + goto done; } -IWL_DEBUG_MAC80211 (priv,"wait transmit/flush all frames\n" ); +IWL_DEBUG_TX_QUEUES (priv,"wait transmit/flush all frames\n" );iwl_trans_wait_tx_queue_empty (priv->trans,0xffffffff ); done:mutex_unlock (&priv->mutex);
Greg Kroah-Hartman
maintainerPATCH 262/319 Revert "iwlwifi: mvm: treat EAPOLs like mgmt frames wrt rate"
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
commit 1ffde699aae127e7abdb98dbdedc2cc6a973a1a1 upstream.
This reverts commit aa11bbf3df026d6b1c6b528bef634fd9de7c2619. This commit was causing connection issues and is not needed if IWL_MVM_RS_RSSI_BASED_INIT_RATE is set to false by default.
Regardless of the issues mentioned above, this patch added the following WARNING:
WARNING: CPU: 0 PID: 3946 at drivers/net/wireless/iwlwifi/mvm/tx.c:190 iwl_mvm_set_tx_params+0x60a/0x6f0 [iwlmvm]() Got an HT rate for a non data frame 0x8 CPU: 0 PID: 3946 Comm: wpa_supplicant Tainted: G O 3.17.0+ #6 Hardware name: LENOVO 20ANCTO1WW/20ANCTO1WW, BIOS GLET71WW (2.25 ) 07/02/2014 0000000000000009 ffffffff814fa911 ffff8804288db8f8 ffffffff81064f52 0000000000001808 ffff8804288db948 ffff88040add8660 ffff8804291b5600 0000000000000000 ffffffff81064fb7 ffffffffa07b73d0 0000000000000020 Call Trace: [<ffffffff814fa911>] ? dump_stack+0x41/0x51 [<ffffffff81064f52>] ? warn_slowpath_common+0x72/0x90 [<ffffffff81064fb7>] ? warn_slowpath_fmt+0x47/0x50 [<ffffffffa07a39ea>] ? iwl_mvm_set_tx_params+0x60a/0x6f0 [iwlmvm] [<ffffffffa07a3cf8>] ? iwl_mvm_tx_skb+0x48/0x3c0 [iwlmvm] [<ffffffffa079cb9b>] ? iwl_mvm_mac_tx+0x7b/0x180 [iwlmvm] [<ffffffffa0746ce9>] ? __ieee80211_tx+0x2b9/0x3c0 [mac80211] [<ffffffffa07492f3>] ? ieee80211_tx+0xb3/0x100 [mac80211] [<ffffffffa0749c49>] ? ieee80211_subif_start_xmit+0x459/0xca0 [mac80211] [<ffffffff814116e7>] ? dev_hard_start_xmit+0x337/0x5f0 [<ffffffff81430d46>] ? sch_direct_xmit+0x96/0x1f0 [<ffffffff81411ba3>] ? __dev_queue_xmit+0x203/0x4f0 [<ffffffff8142f670>] ? ether_setup+0x70/0x70 [<ffffffff814e96a1>] ? packet_sendmsg+0xf81/0x1110 [<ffffffff8140625c>] ? skb_free_datagram+0xc/0x40 [<ffffffff813f7538>] ? sock_sendmsg+0x88/0xc0 [<ffffffff813f7274>] ? move_addr_to_kernel.part.20+0x14/0x60 [<ffffffff811c47c2>] ? __inode_wait_for_writeback+0x62/0xb0 [<ffffffff813f7a91>] ? SYSC_sendto+0xf1/0x180 [<ffffffff813f88f9>] ? __sys_recvmsg+0x39/0x70 [<ffffffff8150066d>] ? system_call_fastpath+0x1a/0x1f ---[ end trace cc19a150d311fc63 ]---
which was reported here: https://bugzilla.kernel.org/show_bug.cgi?id=85691
--- drivers/net/wireless/iwlwifi/mvm/tx.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/wireless/iwlwifi/mvm/tx.c +2 -6
@@ -168,14 +168,10 @@ static void iwl_mvm_set_tx_cmd_rate(stru/* * for data packets, rate info comes from the table inside the fw. This -* table is controlled by LINK_QUALITY commands. Exclude ctrl port -* frames like EAPOLs which should be treated as mgmt frames. This -* avoids them being sent initially in high rates which increases the -* chances for completion of the 4-Way handshake. +* table is controlled by LINK_QUALITY commands */ -if (ieee80211_is_data (fc) && sta && - !(info->control.flags &IEEE80211_TX_CTRL_PORT_CTRL_PROTO )) { +if (ieee80211_is_data (fc) && sta) { tx_cmd->initial_rate_index =0 ; tx_cmd->tx_flags |=cpu_to_le32 (TX_CMD_FLG_STA_RATE );return ;
Greg Kroah-Hartman
maintainerPATCH 263/319 ext3: Dont check quota format when there are no quota files
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 7938db449bbc55bbeb164bec7af406212e7e98f1 upstream.
The check whether quota format is set even though there are no quota files with journalled quota is pointless and it actually makes it impossible to turn off journalled quotas (as there's no way to unset journalled quota format). Just remove the check.
--- fs/ext3/super.c | 7 ------- 1 file changed, 7 deletions(-)
fs/ext3/super.c +0 -7
@@ -1354,13 +1354,6 @@ set_qf_format: "not specified."); return 0; } - }else { -if (sbi->s_jquota_fmt) { -ext3_msg (sb,KERN_ERR ,"error: journaled quota format " -"specified with no journaling " -"enabled." ); -return 0 ; - } }#endif return 1 ;
Greg Kroah-Hartman
maintainerPATCH 264/319 PCI: Rename sysfs enabled file back to enable
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
commit d8e7d53a2fc14e0830ab728cb84ee19933d3ac8d upstream.
Back in commit 5136b2da770d ("PCI: convert bus code to use dev_groups"), I misstyped the 'enable' sysfs filename as 'enabled', which broke the userspace API. This patch fixes that issue by renaming the file back.
--- drivers/pci/pci-sysfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pci/pci-sysfs.c +4 -4
@@ -185,7 +185,7 @@ static ssize_t modalias_show(struct devi }static DEVICE_ATTR_RO (modalias); -static ssize_t enabled_store (struct device *dev,struct device_attribute *attr, +static ssize_t enable_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct pci_dev *pdev =to_pci_dev (dev);
@@ -210,7 +210,7 @@ static ssize_t enabled_store(struct devireturn result <0 ? result : count; } -static ssize_t enabled_show (struct device *dev,struct device_attribute *attr, +static ssize_t enable_show (struct device *dev,struct device_attribute *attr,char *buf) {struct pci_dev *pdev;
@@ -218,7 +218,7 @@ static ssize_t enabled_show(struct devic pdev =to_pci_dev (dev);return sprintf (buf,"%u\n" ,atomic_read (&pdev->enable_cnt)); } -static DEVICE_ATTR_RW (enabled); +static DEVICE_ATTR_RW (enable);#ifdef CONFIG_NUMA static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr,
@@ -564,7 +564,7 @@ static struct attribute *pci_dev_attrs[]#endif &dev_attr_dma_mask_bits.attr, &dev_attr_consistent_dma_mask_bits.attr, - &dev_attr_enabled.attr, + &dev_attr_enable.attr, &dev_attr_broken_parity_status.attr, &dev_attr_msi_bus.attr, #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
Greg Kroah-Hartman
maintainerPATCH 265/319 quota: Properly return errors from dquot_writeback_dquots()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 474d2605d119479e5aa050f738632e63589d4bb5 upstream.
Due to a switched left and right side of an assignment, dquot_writeback_dquots() never returned error. This could result in errors during quota writeback to not be reported to userspace properly. Fix it.
Coverity-id: 1226884
--- fs/quota/dquot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/quota/dquot.c +1 -1
@@ -634,7 +634,7 @@ int dquot_writeback_dquots(struct super_dqstats_inc (DQST_LOOKUPS ); err = sb->dq_op->write_dquot (dquot);if (!ret && err) - err = ret; + ret = err;dqput (dquot);spin_lock (&dq_list_lock); }
Greg Kroah-Hartman
maintainerPATCH 266/319 tty/vt: dont set font mappings on vc not supporting this
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <[email protected]>
commit 9e326f78713a4421fe11afc2ddeac07698fac131 upstream.
We can call this function for a dummy console that doesn't support setting the font mapping, which will result in a null ptr BUG. So check for this case and return error for consoles w/o font mapping support.
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=59321
--- drivers/tty/vt/consolemap.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/tty/vt/consolemap.c +7 -0
@@ -539,6 +539,12 @@ int con_set_unimap(struct vc_data *vc, u/* Save original vc_unipagdir_loc in case we allocate a new one */ p = *vc->vc_uni_pagedir_loc; + +if (!p) { + err = -EINVAL ; + + goto out_unlock; + }if (p->refcount >1 ) {int j, k;
@@ -623,6 +629,7 @@ int con_set_unimap(struct vc_data *vc, uset_inverse_transl (vc, p, i);/* Update inverse translations */ set_inverse_trans_unicode (vc, p); +out_unlock:console_unlock ();return err; }
Greg Kroah-Hartman
maintainerPATCH 267/319 tty: Fix high cpu load if tty is unreleaseable
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Hurley <[email protected]>
commit 37b164578826406a173ca7c20d9ba7430134d23e upstream.
Kernel oops can cause the tty to be unreleaseable (for example, if n_tty_read() crashes while on the read_wait queue). This will cause tty_release() to endlessly loop without sleeping.
Use a killable sleep timeout which grows by 2n+1 jiffies over the interval [0, 120 secs.) and then jumps to forever (but still killable).
NB: killable just allows for the task to be rewoken manually, not to be terminated.
--- drivers/tty/tty_io.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/tty/tty_io.c +6 -1
@@ -1686,6 +1686,7 @@ int tty_release(struct inode *inode, strint pty_master, tty_closing, o_tty_closing, do_sleep;int idx;char buf[64 ]; +long timeout =0 ;if (tty_paranoia_check (tty, inode, __func__))return 0 ;
@@ -1770,7 +1771,11 @@ int tty_release(struct inode *inode, str __func__, tty_name(tty, buf));tty_unlock_pair (tty, o_tty);mutex_unlock (&tty_mutex); -schedule (); +schedule_timeout_killable (timeout); +if (timeout <120 *HZ ) + timeout =2 * timeout +1 ; +else + timeout =MAX_SCHEDULE_TIMEOUT ; }/*
Greg Kroah-Hartman
maintainerPATCH 268/319 PM / Sleep: fix async suspend_late/freeze_late error handling
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <[email protected]>
commit 246ef766743618a7cab059d6c4993270075b173e upstream.
If an asynchronous suspend_late or freeze_late callback fails during the SUSPEND, FREEZE or QUIESCE phases, we don't propagate the corresponding error correctly, in effect ignoring the error and continuing the suspend-to-ram/hibernation. During suspend-to-ram this could leave some devices without a valid saved context, leading to a failure to reinitialize them during resume. During hibernation this could leave some devices active interfeering with the creation / restoration of the hibernation image. Also this could leave the corresponding devices without a valid saved context and failure to reinitialize them during resume.
--- drivers/base/power/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/base/power/main.c +2 -0
@@ -1266,6 +1266,8 @@ static int dpm_suspend_late(pm_message_t }mutex_unlock (&dpm_list_mtx);async_synchronize_full (); +if (!error) + error = async_error;if (error) { suspend_stats.failed_suspend_late++;dpm_save_failed_step (SUSPEND_SUSPEND_LATE );
Greg Kroah-Hartman
maintainerPATCH 269/319 PM / Sleep: fix recovery during resuming from hibernation
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <[email protected]>
commit 94fb823fcb4892614f57e59601bb9d4920f24711 upstream.
If a device's dev_pm_ops::freeze callback fails during the QUIESCE phase, we don't rollback things correctly calling the thaw and complete callbacks. This could leave some devices in a suspended state in case of an error during resuming from hibernation.
--- kernel/power/hibernate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/power/hibernate.c +7 -1
@@ -502,8 +502,14 @@ int hibernation_restore(int platform_mod error =dpm_suspend_start (PMSG_QUIESCE );if (!error) { error =resume_target_kernel (platform_mode); -dpm_resume_end (PMSG_RECOVER ); +/* +* The above should either succeed and jump to the new kernel, +* or return with an error. Otherwise things are just +* undefined, so let's be paranoid. +*/ +BUG_ON (!error); } +dpm_resume_end (PMSG_RECOVER );pm_restore_gfp_mask ();resume_console ();pm_restore_console ();
Greg Kroah-Hartman
maintainerPATCH 270/319 staging: comedi: (regression) channel list must be set for COMEDI_CMD ioctl
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <[email protected]>
commit 6cab7a37f5c048bb2a768f24b0ec748b052fda09 upstream.
do_cmd_ioctl(), the handler for the COMEDI_CMD ioctl can incorrectly call the Comedi subdevice's do_cmd() handler with a NULL channel list pointer. This is a regression as the do_cmd() handler has never been expected to deal with that, leading to a kernel OOPS when it tries to dereference it.
A NULL channel list pointer is allowed for the COMEDI_CMDTEST ioctl, handled by do_cmdtest_ioctl() and the subdevice's do_cmdtest() handler, but not for the COMEDI_CMD ioctl and its handlers.
Both do_cmd_ioctl() and do_cmdtest_ioctl() call __comedi_get_user_chanlist() to copy the channel list from user memory into dynamically allocated kernel memory and check it for consistency. That function currently returns 0 if the user_chanlist parameter (pointing to the channel list in user memory) is NULL. That's fine for do_cmdtest_ioctl(), but do_cmd_ioctl() incorrectly assumes the kernel copy of the channel list has been set-up correctly.
Fix it by not allowing the user_chanlist parameter to be NULL in __comedi_get_user_chanlist(), and only calling it from do_cmdtest_ioctl() if the parameter is non-NULL.
Thanks to Bernd Porr for reporting the bug via an initial patch sent privately.
--- drivers/staging/comedi/comedi_fops.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/staging/comedi/comedi_fops.c +7 -8
@@ -1462,10 +1462,6 @@ static int __comedi_get_user_chanlist(stunsigned int *chanlist;int ret; -/* user_chanlist could be NULL for do_cmdtest ioctls */ -if (!user_chanlist) -return 0 ; - chanlist =memdup_user (user_chanlist, cmd->chanlist_len *sizeof (unsigned int ));if (IS_ERR (chanlist))
@@ -1609,10 +1605,13 @@ static int do_cmdtest_ioctl(struct comed s = &dev->subdevices[cmd.subdev]; -/* load channel/gain list */ - ret =__comedi_get_user_chanlist (dev, s, user_chanlist, &cmd); -if (ret) -return ret; +/* user_chanlist can be NULL for COMEDI_CMDTEST ioctl */ +if (user_chanlist) { +/* load channel/gain list */ + ret =__comedi_get_user_chanlist (dev, s, user_chanlist, &cmd); +if (ret) +return ret; + } ret = s->do_cmdtest (dev, s, &cmd);
Greg Kroah-Hartman
maintainerPATCH 271/319 staging: comedi: fix memory leak / bad pointer freeing for chanlist
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <[email protected]>
commit 238b5ad855924919e5b98d0c772d9dc78795639b upstream.
As a follow-up to commit 6cab7a37f5c04 ("staging: comedi: (regression) channel list must be set for COMEDI_CMD ioctl"), Hartley Sweeten pointed out another couple of bugs stemming from commit 6cab7a37f5c04 ("staging:
comedi: comedi_fops: introduce __comedi_get_user_chanlist()").
Firstly, do_cmdtest_ioctl() never frees the kernel copy of the user chanlist allocated by __comedi_get_user_chanlist(), so that memory is leaked. Fix it by freeing the allocated kernel memory pointed to by cmd.chanlist before that pointer is overwritten with its original pointer to user memory before cmd is copied back to user-space.
Secondly, if __comedi_get_user_chanlist() returns an error, cmd->chanlist is left unchanged and in fact will be a pointer to user memory. This causes do_cmd_ioctl() to goto cleanup and call do_become_nonbusy() which would attempt to free the memory pointed to by the user-space pointer. Fix it by setting cmd->chanlist to NULL at the start of __comedi_get_user_chanlist().
--- drivers/staging/comedi/comedi_fops.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/staging/comedi/comedi_fops.c +3 -0
@@ -1462,6 +1462,7 @@ static int __comedi_get_user_chanlist(stunsigned int *chanlist;int ret; + cmd->chanlist =NULL ; chanlist =memdup_user (user_chanlist, cmd->chanlist_len *sizeof (unsigned int ));if (IS_ERR (chanlist))
@@ -1615,6 +1616,8 @@ static int do_cmdtest_ioctl(struct comed ret = s->do_cmdtest (dev, s, &cmd); +kfree (cmd.chanlist);/* free kernel copy of user chanlist */ +/* restore chanlist pointer before copying back */ cmd.chanlist = (unsigned int __force *)user_chanlist;
Greg Kroah-Hartman
maintainerPATCH 272/319 mac80211: fix typo in starting baserate for rts_cts_rate_idx
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Beldan <[email protected]>
commit c7abf25af0f41be4b50d44c5b185d52eea360cb8 upstream.
It affects non-(V)HT rates and can lead to selecting an rts_cts rate that is not a basic rate or way superior to the reference rate (ATM rates[0] used for the 1st attempt of the protected frame data).
E.g, assuming drivers register growing (bitrate) sorted tables of ieee80211_rate-s, having :
- rates[0].idx == d'2 and basic_rates == b'10100
will select rts_cts idx b'10011 & ~d'(BIT(2)-1), i.e. 1, likewise
- rates[0].idx == d'2 and basic_rates == b'10001
will select rts_cts idx b'10000
The first is not a basic rate and the second is > rates[0].
Also, wrt severity of the addressed misbehavior, ATM we only have one rts_cts_rate_idx rather than one per rate table entry, so this idx might still point to bitrates > rates[1..MAX_RATES].
--- net/mac80211/rate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/rate.c +1 -1
@@ -448,7 +448,7 @@ static void rate_fixup_ratelist(struct i*/ if (!(rates[0 ].flags &IEEE80211_TX_RC_MCS )) {u32 basic_rates = vif->bss_conf.basic_rates; -s8 baserate = basic_rates ?ffs (basic_rates -1 ) :0 ; +s8 baserate = basic_rates ?ffs (basic_rates) -1 :0 ; rate = &sband->bitrates[rates[0 ].idx];
Greg Kroah-Hartman
maintainerPATCH 273/319 mtd: cfi_cmdset_0001.c: fix resume for LH28F640BF chips
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Eremin-Solenikov <[email protected]>
commit 89cf38dd536a7301d6b5f5ddd73f42074c01bfaa upstream.
After '#echo mem > /sys/power/state' some devices can not be properly resumed because apparently the MTD Partition Configuration Register has been reset to default thus the rootfs cannot be mounted cleanly on resume. An example of this can be found in the SA-1100 Developer's Manual at 9.5.3.3 where the second step of the Sleep Shutdown Sequence is described:
"An internal reset is applied to the SA-1100. All units are reset...".
As workaround we refresh the PCR value as done initially on chip setup.
This behavior and the fix are confirmed by our tests done on 2 different Zaurus collie units with kernel 3.17.
--- drivers/mtd/chips/cfi_cmdset_0001.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/chips/cfi_cmdset_0001.c +2 -0
@@ -2590,6 +2590,8 @@ static void cfi_intelext_resume(struct m/* Go to known state. Chip may have been power cycled */ if (chip->state ==FL_PM_SUSPENDED ) { +/* Refresh LH28F640BF Partition Config. Register */ +fixup_LH28F640BF (mtd);map_write (map,CMD (0xFF ), cfi->chips[i].start); chip->oldstate = chip->state =FL_READY ;wake_up (&chip->wq);
Greg Kroah-Hartman
maintainerPATCH 274/319 posix-timers: Fix stack info leak in timer_create()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Krause <[email protected]>
commit 6891c4509c792209c44ced55a60f13954cb50ef4 upstream.
If userland creates a timer without specifying a sigevent info, we'll create one ourself, using a stack local variable. Particularly will we use the timer ID as sival_int. But as sigev_value is a union containing a pointer and an int, that assignment will only partially initialize sigev_value on systems where the size of a pointer is bigger than the size of an int. On such systems we'll copy the uninitialized stack bytes from the timer_create() call to userland when the timer actually fires and we're going to deliver the signal.
Initialize sigev_value with 0 to plug the stack info leak.
Found in the PaX patch, written by the PaX Team.
--- kernel/time/posix-timers.c | 1 + 1 file changed, 1 insertion(+)
kernel/time/posix-timers.c +1 -0
@@ -636,6 +636,7 @@ SYSCALL_DEFINE3(timer_create, const cloc goto out; } }else { +memset (&event.sigev_value,0 ,sizeof (event.sigev_value)); event.sigev_notify =SIGEV_SIGNAL ; event.sigev_signo =SIGALRM ; event.sigev_value.sival_int = new_timer->it_id;
Greg Kroah-Hartman
maintainerPATCH 275/319 x86, apic: Handle a bad TSC more gracefully
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Lutomirski <[email protected]>
commit b47dcbdc5161d3d5756f430191e2840d9b855492 upstream.
If the TSC is unusable or disabled, then this patch fixes:
- Confusion while trying to clear old APIC interrupts.
- Division by zero and incorrect programming of the TSC deadline timer.
This fixes boot if the CPU has a TSC deadline timer but a missing or broken TSC. The failure to boot can be observed with qemu using -cpu qemu64,-tsc,+tsc-deadline
This also happens to me in nested KVM for unknown reasons. With this patch, I can boot cleanly (although without a TSC).
--- arch/x86/kernel/apic/apic.c | 4 ++-- arch/x86/kernel/tsc.c | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)
arch/x86/kernel/apic/apic.c +2 -2
@@ -1297,7 +1297,7 @@ void setup_local_APIC(void)unsigned int value, queued;int i, j, acked =0 ;unsigned long long tsc =0 , ntsc; -long long max_loops = cpu_khz; +long long max_loops = cpu_khz ? cpu_khz :1000000 ;if (cpu_has_tsc)rdtscll (tsc);
@@ -1383,7 +1383,7 @@ void setup_local_APIC(void)break ; }if (queued) { -if (cpu_has_tsc) { +if (cpu_has_tsc && cpu_khz) {rdtscll (ntsc); max_loops = (cpu_khz <<10 ) - (ntsc - tsc); }else
arch/x86/kernel/tsc.c +4 -1
@@ -1166,14 +1166,17 @@ void __init tsc_init(void) x86_init.timers.tsc_pre_init (); -if (!cpu_has_tsc) +if (!cpu_has_tsc) { +setup_clear_cpu_cap (X86_FEATURE_TSC_DEADLINE_TIMER );return ; + } tsc_khz = x86_platform.calibrate_tsc (); cpu_khz = tsc_khz;if (!tsc_khz) {mark_tsc_unstable ("could not calculate TSC khz" ); +setup_clear_cpu_cap (X86_FEATURE_TSC_DEADLINE_TIMER );return ; }
Greg Kroah-Hartman
maintainerPATCH 276/319 mm: Remove false WARN_ON from pagecache_isize_extended()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit f55fefd1a5a339b1bd08c120b93312d6eb64a9fb upstream.
The WARN_ON checking whether i_mutex is held in pagecache_isize_extended() was wrong because some filesystems (e.g. XFS) use different locks for serialization of truncates / writes. So just remove the check.
--- mm/truncate.c | 1 - 1 file changed, 1 deletion(-)
mm/truncate.c +0 -1
@@ -755,7 +755,6 @@ void pagecache_isize_extended(struct inostruct page *page;pgoff_t index; -WARN_ON (!mutex_is_locked (&inode->i_mutex));WARN_ON (to > inode->i_size);if (from >= to || bsize ==PAGE_CACHE_SIZE )
Greg Kroah-Hartman
maintainerPATCH 277/319 media: Remove references to non-existent PLAT_S5P symbol
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sylwester Nawrocki <[email protected]>
commit 098bcd2335f0824e76dd835e4e2b7ae8e38fc281 upstream.
The PLAT_S5P Kconfig symbol was removed in commit d78c16ccde96 ("ARM: SAMSUNG: Remove remaining legacy code"). However, there are still some references to that symbol left, fix that by substituting them with ARCH_S5PV210.
--- drivers/media/platform/Kconfig | 6 +++--- drivers/media/platform/exynos4-is/Kconfig | 2 +- drivers/media/platform/s5p-tv/Kconfig | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/media/platform/Kconfig +3 -3
@@ -158,7 +158,7 @@ config VIDEO_MEM2MEM_DEINTERLACE config VIDEO_SAMSUNG_S5P_G2D tristate "Samsung S5P and EXYNOS4 G2D 2d graphics accelerator driver" - depends on VIDEO_DEV && VIDEO_V4L2 && (PLAT_S5P || ARCH_EXYNOS) + depends on VIDEO_DEV && VIDEO_V4L2 && (ARCH_S5PV210 || ARCH_EXYNOS) select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV default n
@@ -168,7 +168,7 @@ config VIDEO_SAMSUNG_S5P_G2D config VIDEO_SAMSUNG_S5P_JPEG tristate "Samsung S5P/Exynos3250/Exynos4 JPEG codec driver" - depends on VIDEO_DEV && VIDEO_V4L2 && (PLAT_S5P || ARCH_EXYNOS) + depends on VIDEO_DEV && VIDEO_V4L2 && (ARCH_S5PV210 || ARCH_EXYNOS) select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV ---help---
@@ -177,7 +177,7 @@ config VIDEO_SAMSUNG_S5P_JPEG config VIDEO_SAMSUNG_S5P_MFC tristate "Samsung S5P MFC Video Codec" - depends on VIDEO_DEV && VIDEO_V4L2 && (PLAT_S5P || ARCH_EXYNOS) + depends on VIDEO_DEV && VIDEO_V4L2 && (ARCH_S5PV210 || ARCH_EXYNOS) select VIDEOBUF2_DMA_CONTIG default n help
drivers/media/platform/exynos4-is/Kconfig +1 -1
@@ -2,7 +2,7 @@ config VIDEO_SAMSUNG_EXYNOS4_IS bool "Samsung S5P/EXYNOS4 SoC series Camera Subsystem driver" depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API - depends on (PLAT_S5P || ARCH_EXYNOS) + depends on ARCH_S5PV210 || ARCH_EXYNOS depends on OF && COMMON_CLK help Say Y here to enable camera host interface devices for
drivers/media/platform/s5p-tv/Kconfig +1 -1
@@ -8,7 +8,7 @@ config VIDEO_SAMSUNG_S5P_TV bool "Samsung TV driver for S5P platform" - depends on (PLAT_S5P || ARCH_EXYNOS) && PM_RUNTIME + depends on (ARCH_S5PV210 || ARCH_EXYNOS) && PM_RUNTIME default n ---help--- Say Y here to enable selecting the TV output devices for
Greg Kroah-Hartman
maintainerPATCH 278/319 crypto: algif - avoid excessive use of socket buffer in skcipher
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ondrej Kozina <[email protected]>
commit e2cffb5f493a8b431dc87124388ea59b79f0bccb upstream.
On archs with PAGE_SIZE >= 64 KiB the function skcipher_alloc_sgl() fails with -ENOMEM no matter what user space actually requested. This is caused by the fact sock_kmalloc call inside the function tried to allocate more memory than allowed by the default kernel socket buffer size (kernel param net.core.optmem_max).
--- crypto/algif_skcipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/algif_skcipher.c +1 -1
@@ -49,7 +49,7 @@ struct skcipher_ctx {struct ablkcipher_request req; }; -#define MAX_SGL_ENTS ((PAGE_SIZE - sizeof(struct skcipher_sg_list)) / \ +#define MAX_SGL_ENTS ((4096 - sizeof(struct skcipher_sg_list)) / \ sizeof(struct scatterlist) - 1)static inline int skcipher_sndbuf (struct sock *sk)
Greg Kroah-Hartman
maintainerPATCH 279/319 mtd: m25p80: Fix module aliases for m25p80
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <[email protected]>
Based on a5b7616c55e188fe3d6ef686bef402d4703ecb62, but backported so that a bunch of dependencies are not needed.
m25p80's device ID table is now spi_nor_ids, defined in spi-nor. The MODULE_DEVICE_TABLE() macro doesn't work with extern definitions, but its use was also removed at the same time. Now if m25p80 is built as a module it doesn't get the necessary aliases to be loaded automatically.
A clean solution to this will involve defining the list of device IDs in spi-nor.h and removing struct spi_device_id from the spi-nor API, but this is quite a large change.
As a quick fix suitable for stable, copy the device IDs back into m25p80.
--- drivers/mtd/devices/m25p80.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
drivers/mtd/devices/m25p80.c +50 -0
@@ -245,6 +245,56 @@ static int m25p_remove(struct spi_device } +/* +* XXX This needs to be kept in sync with spi_nor_ids. We can't share +* it with spi-nor, because if this is built as a module then modpost +* won't be able to read it and add appropriate aliases. +*/ +static const struct spi_device_id m25p_ids[] = { + {"at25fs010" }, {"at25fs040" }, {"at25df041a" }, {"at25df321a" }, + {"at25df641" }, {"at26f004" }, {"at26df081a" }, {"at26df161a" }, + {"at26df321" }, {"at45db081d" }, + {"en25f32" }, {"en25p32" }, {"en25q32b" }, {"en25p64" }, + {"en25q64" }, {"en25qh128" }, {"en25qh256" }, + {"f25l32pa" }, + {"mr25h256" }, {"mr25h10" }, + {"gd25q32" }, {"gd25q64" }, + {"160s33b" }, {"320s33b" }, {"640s33b" }, + {"mx25l2005a" }, {"mx25l4005a" }, {"mx25l8005" }, {"mx25l1606e" }, + {"mx25l3205d" }, {"mx25l3255e" }, {"mx25l6405d" }, {"mx25l12805d" }, + {"mx25l12855e" },{"mx25l25635e" },{"mx25l25655e" },{"mx66l51235l" }, + {"mx66l1g55g" }, + {"n25q064" }, {"n25q128a11" }, {"n25q128a13" }, {"n25q256a" }, + {"n25q512a" }, {"n25q512ax3" }, {"n25q00" }, + {"pm25lv512" }, {"pm25lv010" }, {"pm25lq032" }, + {"s25sl032p" }, {"s25sl064p" }, {"s25fl256s0" }, {"s25fl256s1" }, + {"s25fl512s" }, {"s70fl01gs" }, {"s25sl12800" }, {"s25sl12801" }, + {"s25fl129p0" }, {"s25fl129p1" }, {"s25sl004a" }, {"s25sl008a" }, + {"s25sl016a" }, {"s25sl032a" }, {"s25sl064a" }, {"s25fl008k" }, + {"s25fl016k" }, {"s25fl064k" }, + {"sst25vf040b" },{"sst25vf080b" },{"sst25vf016b" },{"sst25vf032b" }, + {"sst25vf064c" },{"sst25wf512" }, {"sst25wf010" }, {"sst25wf020" }, + {"sst25wf040" }, + {"m25p05" }, {"m25p10" }, {"m25p20" }, {"m25p40" }, + {"m25p80" }, {"m25p16" }, {"m25p32" }, {"m25p64" }, + {"m25p128" }, {"n25q032" }, + {"m25p05-nonjedec" }, {"m25p10-nonjedec" }, {"m25p20-nonjedec" }, + {"m25p40-nonjedec" }, {"m25p80-nonjedec" }, {"m25p16-nonjedec" }, + {"m25p32-nonjedec" }, {"m25p64-nonjedec" }, {"m25p128-nonjedec" }, + {"m45pe10" }, {"m45pe80" }, {"m45pe16" }, + {"m25pe20" }, {"m25pe80" }, {"m25pe16" }, + {"m25px16" }, {"m25px32" }, {"m25px32-s0" }, {"m25px32-s1" }, + {"m25px64" }, + {"w25x10" }, {"w25x20" }, {"w25x40" }, {"w25x80" }, + {"w25x16" }, {"w25x32" }, {"w25q32" }, {"w25q32dw" }, + {"w25x64" }, {"w25q64" }, {"w25q128" }, {"w25q80" }, + {"w25q80bl" }, {"w25q128" }, {"w25q256" }, {"cat25c11" }, + {"cat25c03" }, {"cat25c09" }, {"cat25c17" }, {"cat25128" }, + { }, +}; +MODULE_DEVICE_TABLE (spi, m25p_ids); + +static struct spi_driver m25p80_driver = { .driver = { .name ="m25p80" ,
Greg Kroah-Hartman
maintainerPATCH 280/319 usb: dwc3: gadget: fix set_halt() bug with pending transfers
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
[ Upstream commit 7a60855972f0d3c014093046cb6f013a1ee5bb19 ]
According to our Gadget Framework API documentation, ->set_halt() *must* return -EAGAIN if we have pending transfers (on either direction) or FIFO isn't empty (on TX endpoints).
Fix this bug so that the mass storage gadget can be used without stall=0 parameter.
This patch should be backported to all kernels since v3.2.
--- drivers/usb/dwc3/ep0.c | 4 ++-- drivers/usb/dwc3/gadget.c | 16 ++++++++++++---- drivers/usb/dwc3/gadget.h | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-)
drivers/usb/dwc3/ep0.c +2 -2
@@ -251,7 +251,7 @@ static void dwc3_ep0_stall_and_restart(s/* stall is always issued on EP0 */ dep = dwc->eps[0 ]; -__dwc3_gadget_ep_set_halt (dep,1 ); +__dwc3_gadget_ep_set_halt (dep,1 , false); dep->flags =DWC3_EP_ENABLED ; dwc->delayed_status = false;
@@ -461,7 +461,7 @@ static int dwc3_ep0_handle_feature(strucreturn -EINVAL ;if (set ==0 && (dep->flags &DWC3_EP_WEDGE ))break ; - ret =__dwc3_gadget_ep_set_halt (dep, set); + ret =__dwc3_gadget_ep_set_halt (dep, set, true);if (ret)return -EINVAL ;break ;
drivers/usb/dwc3/gadget.c +12 -4
@@ -670,7 +670,7 @@ static int __dwc3_gadget_ep_disable(stru/* make sure HW endpoint isn't stalled */ if (dep->flags &DWC3_EP_STALL ) -__dwc3_gadget_ep_set_halt (dep,0 ); +__dwc3_gadget_ep_set_halt (dep,0 , false); reg =dwc3_readl (dwc->regs,DWC3_DALEPENA ); reg &= ~DWC3_DALEPENA_EP (dep->number);
@@ -1286,7 +1286,7 @@ out0:return ret; } -int __dwc3_gadget_ep_set_halt (struct dwc3_ep *dep,int value) +int __dwc3_gadget_ep_set_halt (struct dwc3_ep *dep,int value,int protocol) {struct dwc3_gadget_ep_cmd_params params;struct dwc3 *dwc = dep->dwc;
@@ -1295,6 +1295,14 @@ int __dwc3_gadget_ep_set_halt(struct dwcmemset (¶ms,0x00 ,sizeof (params));if (value) { +if (!protocol && ((dep->direction && dep->flags &DWC3_EP_BUSY ) || + (!list_empty (&dep->req_queued) || + !list_empty (&dep->request_list)))) { +dev_dbg (dwc->dev,"%s: pending request, cannot halt\n" , + dep->name); +return -EAGAIN ; + } + ret =dwc3_send_gadget_ep_cmd (dwc, dep->number,DWC3_DEPCMD_SETSTALL , ¶ms);if (ret)
@@ -1332,7 +1340,7 @@ static int dwc3_gadget_ep_set_halt(struc goto out; } - ret =__dwc3_gadget_ep_set_halt (dep, value); + ret =__dwc3_gadget_ep_set_halt (dep, value, false); out:spin_unlock_irqrestore (&dwc->lock, flags);
@@ -1352,7 +1360,7 @@ static int dwc3_gadget_ep_set_wedge(struif (dep->number ==0 || dep->number ==1 )return dwc3_gadget_ep0_set_halt (ep,1 );else -return dwc3_gadget_ep_set_halt (ep,1 ); +return __dwc3_gadget_ep_set_halt (dep,1 , false); }/* -------------------------------------------------------------------------- */
drivers/usb/dwc3/gadget.h +1 -1
@@ -85,7 +85,7 @@ void dwc3_ep0_out_start(struct dwc3 *dwcint dwc3_gadget_ep0_set_halt (struct usb_ep *ep,int value);int dwc3_gadget_ep0_queue (struct usb_ep *ep,struct usb_request *request,gfp_t gfp_flags); -int __dwc3_gadget_ep_set_halt (struct dwc3_ep *dep,int value); +int __dwc3_gadget_ep_set_halt (struct dwc3_ep *dep,int value,int protocol);/** * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW
Greg Kroah-Hartman
maintainerPATCH 281/319 usb: gadget: function: acm: make f_acm pass USB20CV Chapter9
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
[ Upstream commit 52ec49a5e56a27c5b6f8217708783eff39f24c16 ]
During Halt Endpoint Test, our interrupt endpoint will be disabled, which will clear out ep->desc to NULL. Unless we call config_ep_by_speed() again, we will not be able to enable this endpoint which will make us fail that test.
inside the struct usb_ep on disable)
--- drivers/usb/gadget/function/f_acm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/gadget/function/f_acm.c +4 -3
@@ -430,11 +430,12 @@ static int acm_set_alt(struct usb_functiif (acm->notify->driver_data) {VDBG (cdev,"reset acm control interface %d\n" , intf);usb_ep_disable (acm->notify); - }else { -VDBG (cdev,"init acm ctrl interface %d\n" , intf); + } + +if (!acm->notify->desc)if (config_ep_by_speed (cdev->gadget, f, acm->notify))return -EINVAL ; - } +usb_ep_enable (acm->notify); acm->notify->driver_data = acm;
Greg Kroah-Hartman
maintainerPATCH 282/319 sched: Use rq->rd in sched_setaffinity() under RCU read lock
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kirill Tkhai <[email protected]>
commit f1e3a0932f3a9554371792a7daaf1e0eb19f66d5 upstream.
Probability of use-after-free isn't zero in this place.
--- kernel/sched/core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/sched/core.c +5 -4
@@ -4008,13 +4008,14 @@ long sched_setaffinity(pid_t pid, const* root_domain. */ #ifdef CONFIG_SMP -if (task_has_dl_policy (p)) { -const struct cpumask *span =task_rq (p)->rd->span; - -if (dl_bandwidth_enabled () && !cpumask_subset (span, new_mask)) { +if (task_has_dl_policy (p) &&dl_bandwidth_enabled ()) { +rcu_read_lock (); +if (!cpumask_subset (task_rq (p)->rd->span, new_mask)) { retval = -EBUSY ; +rcu_read_unlock (); goto out_unlock; } +rcu_read_unlock (); }#endif again:
Greg Kroah-Hartman
maintainerPATCH 283/319 x86, intel-mid: Create IRQs for APB timers and RTC timers
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiang Liu <[email protected]>
commit f18298595aefa2c836a128ec6e0f75f39965dd81 upstream.
Intel MID platforms has no legacy interrupts, so no IRQ descriptors preallocated. We need to call mp_map_gsi_to_irq() to create IRQ descriptors for APB timers and RTC timers, otherwise it may cause invalid memory access as:
[ 0.116839] BUG: unable to handle kernel NULL pointer dereference at 0000003a [ 0.123803] IP: [<c1071c0e>] setup_irq+0xf/0x4d
--- arch/x86/kernel/apb_timer.c | 2 -- arch/x86/platform/intel-mid/sfi.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/apb_timer.c +0 -2
@@ -185,8 +185,6 @@ static void apbt_setup_irq(struct apbt_dirq_modify_status (adev->irq,0 ,IRQ_MOVE_PCNTXT );irq_set_affinity (adev->irq,cpumask_of (adev->cpu)); -/* APB timer irqs are set up as mp_irqs, timer is edge type */ -__irq_set_handler (adev->irq, handle_edge_irq,0 ,"edge" ); }/* Should be called with per cpu */
arch/x86/platform/intel-mid/sfi.c +2 -0
@@ -106,6 +106,7 @@ int __init sfi_parse_mtmr(struct sfi_tab mp_irq.dstapic =MP_APIC_ALL ; mp_irq.dstirq = pentry->irq;mp_save_irq (&mp_irq); +mp_map_gsi_to_irq (pentry->irq,IOAPIC_MAP_ALLOC ); }return 0 ;
@@ -176,6 +177,7 @@ int __init sfi_parse_mrtc(struct sfi_tab mp_irq.dstapic =MP_APIC_ALL ; mp_irq.dstirq = pentry->irq;mp_save_irq (&mp_irq); +mp_map_gsi_to_irq (pentry->irq,IOAPIC_MAP_ALLOC ); }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 284/319 drm/vmwgfx: Filter out modes those cannot be supported by the current VRAM size.
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sinclair Yeh <[email protected]>
commit 9a72384d86b26cb8a2b25106677e1197f606668f upstream.
When screen objects are enabled, the bpp is assumed to be 32, otherwise it is set to 16.
v2:
* Use u32 instead of u64 for assumed_bpp.
* Fixed mechanism to check for screen objects
* Limit the back buffer size to VRAM.
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 6 +++++- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +5 -1
@@ -688,7 +688,11 @@ static int vmw_driver_load(struct drm_de goto out_err0; } -if (unlikely (dev_priv->prim_bb_mem < dev_priv->vram_size)) +/* +* Limit back buffer size to VRAM size. Remove this once +* screen targets are implemented. +*/ +if (dev_priv->prim_bb_mem > dev_priv->vram_size) dev_priv->prim_bb_mem = dev_priv->vram_size;mutex_unlock (&dev_priv->hw_mutex);
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +13 -3
@@ -1950,6 +1950,14 @@ int vmw_du_connector_fill_modes(struct d DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) };int i; +u32 assumed_bpp =2 ; + +/* +* If using screen objects, then assume 32-bpp because that's what the +* SVGA device is assuming +*/ +if (dev_priv->sou_priv) + assumed_bpp =4 ;/* Add preferred mode */ {
@@ -1960,8 +1968,9 @@ int vmw_du_connector_fill_modes(struct d mode->vdisplay = du->pref_height;vmw_guess_mode_timing (mode); -if (vmw_kms_validate_mode_vram (dev_priv, mode->hdisplay *2 , - mode->vdisplay)) { +if (vmw_kms_validate_mode_vram (dev_priv, + mode->hdisplay * assumed_bpp, + mode->vdisplay)) {drm_mode_probed_add (connector, mode); }else {drm_mode_destroy (dev, mode);
@@ -1983,7 +1992,8 @@ int vmw_du_connector_fill_modes(struct d bmode->vdisplay > max_height)continue ; -if (!vmw_kms_validate_mode_vram (dev_priv, bmode->hdisplay *2 , +if (!vmw_kms_validate_mode_vram (dev_priv, + bmode->hdisplay * assumed_bpp, bmode->vdisplay))continue ;
Greg Kroah-Hartman
maintainerPATCH 285/319 drm/radeon/dpm: disable ulv support on SI
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 6fa455935ab956248b165f150ec6ae9106210077 upstream.
Causes problems on some boards.
bug:
https://bugs.freedesktop.org/show_bug.cgi?id=82889
--- drivers/gpu/drm/radeon/si_dpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/si_dpm.c +1 -1
@@ -6255,7 +6255,7 @@ static void si_parse_pplib_clock_info(stif ((rps->class2 &ATOM_PPLIB_CLASSIFICATION2_ULV ) && index ==0 ) {/* XXX disable for A0 tahiti */ - si_pi->ulv.supported = true; + si_pi->ulv.supported = false; si_pi->ulv.pl = *pl; si_pi->ulv.one_pcie_lane_in_ulv = false; si_pi->ulv.volt_change_delay =SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT ;
Greg Kroah-Hartman
maintainerPATCH 287/319 drm/radeon: dpm fixes for asrock systems
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 72b3f9183ed57e4a2f0601a1c25ae2fd39855952 upstream.
- bapm seems to cause CPU stuck messages so disable it.
- nb dpm seems to prevent GPU dpm from getting enabled, so disable it.
bug:
https://bugs.freedesktop.org/show_bug.cgi?id=85107
--- drivers/gpu/drm/radeon/kv_dpm.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/kv_dpm.c +16 -3
@@ -2725,7 +2725,11 @@ int kv_dpm_init(struct radeon_device *rd pi->sram_end =SMC_RAM_END ; - pi->enable_nb_dpm = true; +/* Enabling nb dpm on an asrock system prevents dpm from working */ +if (rdev->pdev->subsystem_vendor ==0x1849 ) + pi->enable_nb_dpm = false; +else + pi->enable_nb_dpm = true; pi->caps_power_containment = true; pi->caps_cac = true;
@@ -2740,10 +2744,19 @@ int kv_dpm_init(struct radeon_device *rd pi->caps_sclk_ds = true; pi->enable_auto_thermal_throttling = true; pi->disable_nb_ps3_in_battery = false; -if (radeon_bapm ==0 ) +if (radeon_bapm ==-1 ) { +/* There are stability issues reported on with +* bapm enabled on an asrock system. +*/ +if (rdev->pdev->subsystem_vendor ==0x1849 ) + pi->bapm_enable = false; +else + pi->bapm_enable = true; + }else if (radeon_bapm ==0 ) { pi->bapm_enable = false; -else + }else { pi->bapm_enable = true; + } pi->voltage_drop_t =0 ; pi->caps_sclk_throttle_low_notification = false; pi->caps_fps = false;/* true? */
Greg Kroah-Hartman
maintainerPATCH 288/319 drm/radeon: remove invalid pci id
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 8c3e434769b1707fd2d24de5a2eb25fedc634c4a upstream.
0x4c6e is a secondary device id so should not be used by the driver.
--- include/drm/drm_pciids.h | 1 - 1 file changed, 1 deletion(-)
include/drm/drm_pciids.h +0 -1
@@ -74,7 +74,6 @@ {0x1002, 0x4C64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ {0x1002, 0x4C66, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ {0x1002, 0x4C67, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ - {0x1002, 0x4C6E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|RADEON_IS_MOBILITY}, \ {0x1002, 0x4E44, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ {0x1002, 0x4E45, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ {0x1002, 0x4E46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
Greg Kroah-Hartman
maintainerPATCH 292/319 mm: cma: Dont crash on allocation if CMA area cant be activated
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
commit f022d8cb7ec70fe8edd56383d876001317ee76b1 upstream.
If activation of the CMA area fails its mutex won't be initialized, leading to an oops at allocation time when trying to lock the mutex. Fix this by setting the cma area count field to 0 when activation fails, leading to allocation returning NULL immediately.
--- mm/cma.c | 1 + 1 file changed, 1 insertion(+)
mm/cma.c +1 -0
@@ -123,6 +123,7 @@ static int __init cma_activate_area(stru err:kfree (cma->bitmap); + cma->count =0 ;return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 293/319 rbd: Fix error recovery in rbd_obj_read_sync()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit a8d4205623ae965e36c68629db306ca0695a2771 upstream.
When we fail to allocate page vector in rbd_obj_read_sync() we just basically ignore the problem and continue which will result in an oops later. Fix the problem by returning proper error.
CC: Yehuda Sadeh <[email protected]>
CC: Sage Weil <[email protected]>
CC: [email protected]
Coverity-id: 1226882
--- drivers/block/rbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rbd.c +1 -1
@@ -3382,7 +3382,7 @@ static int rbd_obj_read_sync(struct rbd_ page_count = (u32 )calc_pages_for (offset, length); pages =ceph_alloc_page_vector (page_count,GFP_KERNEL );if (IS_ERR (pages)) - ret =PTR_ERR (pages); +return PTR_ERR (pages); ret = -ENOMEM ; obj_request = rbd_obj_request_create(object_name, offset, length,
Greg Kroah-Hartman
maintainerPATCH 294/319 acer-wmi: Add acpi_backlight=video quirk for the Acer KAV80
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 183fd8fcd7f8afb7ac5ec68f83194872f9fecc84 upstream.
The acpi-video backlight interface on the Acer KAV80 is broken, and worse it causes the entire machine to slow down significantly after a suspend/resume.
Blacklist it, and use the acer-wmi backlight interface instead. Note that the KAV80 is somewhat unique in that it is the only Acer model where we fall back to acer-wmi after blacklisting, rather then using the native (e.g. intel) backlight driver. This is done because there is no native backlight interface on this model.
--- drivers/platform/x86/acer-wmi.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/platform/x86/acer-wmi.c +11 -0
@@ -579,6 +579,17 @@ static const struct dmi_system_id video_ DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5741"), }, }, + { + /* + * Note no video_set_backlight_video_vendor, we must use the + * acer interface, as there is no native backlight interface. + */ + .ident = "Acer KAV80", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), + DMI_MATCH(DMI_PRODUCT_NAME, "KAV80"), + }, + }, {} };
Greg Kroah-Hartman
maintainerPATCH 295/319 samsung-laptop: Add broken-acpi-video quirk for NC210/NC110
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 5a1426c99f9b7aa11d60c4e6b7a3211bb5321696 upstream.
The acpi-video backlight interface on the NC210 does not work, blacklist it and use the samsung-laptop interface instead.
--- drivers/platform/x86/samsung-laptop.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/platform/x86/samsung-laptop.c +10 -0
@@ -1561,6 +1561,16 @@ static struct dmi_system_id __initdata s }, { .callback = samsung_dmi_matched, + .ident = "NC210", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"SAMSUNG ELECTRONICS CO., LTD." ), +DMI_MATCH (DMI_PRODUCT_NAME ,"NC210/NC110" ), + DMI_MATCH(DMI_BOARD_NAME, "NC210/NC110"), + }, + .driver_data = &samsung_broken_acpi_video, + }, + { + .callback = samsung_dmi_matched, .ident = "730U3E/740U3E", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
Greg Kroah-Hartman
maintainerPATCH 296/319 fix breakage in o2net_send_tcp_msg()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 7e8631e8b9d4e9f698c09c7e7309c96249180ff9 upstream.
uninitialized msghdr. Broken in "ocfs2: don't open-code kernel_recvmsg()" by me ;-/
--- fs/ocfs2/cluster/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/cluster/tcp.c +1 -1
@@ -925,7 +925,7 @@ static int o2net_send_tcp_msg(struct soc size_t veclen, size_t total) { int ret; -struct msghdr msg; +struct msghdr msg = {.msg_flags =0 ,};if (sock ==NULL ) { ret = -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 297/319 pinctrl: baytrail: show output gpio state correctly on Intel Baytrail
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Cohen <[email protected]>
commit d90c33818967c5e5371961604ad98b4dea4fa3f4 upstream.
Even if a gpio pin is set to output, we still need to set INPUT_EN functionality (by clearing INPUT_EN bit) to be able to read the pin's level.
E.g. without this change, we'll always read low level state from sysfs.
--- drivers/pinctrl/pinctrl-baytrail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-baytrail.c +1 -1
@@ -318,7 +318,7 @@ static int byt_gpio_direction_output(str "Potential Error: Setting GPIO with direct_irq_en to output"); reg_val =readl (reg) |BYT_DIR_MASK ; - reg_val &= ~BYT_OUTPUT_EN ; + reg_val &= ~(BYT_OUTPUT_EN |BYT_INPUT_EN );if (value)writel (reg_val |BYT_LEVEL , reg);
Greg Kroah-Hartman
maintainerPATCH 298/319 ARM: pxa: fix hang on startup with DEBUG_LL
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Jarzmik <[email protected]>
commit cde7fc879969f933614b1256df2625d6ff637bab upstream.
The commit 2111667b4677 ("ARM: pxa: call debug_ll_io_init for earlyprintk") triggers in the current kernel the attached backtrace on PXA/tosa early in the boot time when DEBUG_LL is enabled.
It is due to overlap between uart virtual memory defined in DEBUG_UART_VIRT and mapped by debug_ll_io_init() and peripheral bus mapped by pxa_map_io at the same address, 0xf2100000.
As hinted by Arnd, map early virtual memory for low level debug on address 0xf6200000, even if that means 2 virtual mappings will give access to the pxa internal UARTs (FFUART, BTUART, STUART, ...).
------------[ cut here ]------------ kernel BUG at /home/lumag/linux/mm/vmalloc.c:1143! Internal error: Oops - BUG: 0 [#1] PREEMPT ARM Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 3.17.0-00032-g8e0d202-dirty #23 task: c062a5a8 ti: c0620000 task.ti: c0620000 PC is at vm_area_add_early+0x54/0x84 LR is at add_static_vm_early+0xc/0x60 pc : [<c03e1100>] lr : [<c03d9ef4>] psr: 800001d3
sp : c0621f04 ip : c03efa74 fp : c03edf84
r10: c0637e98 r9 : 40000001 r8 : c03da57c
r7 : c3ffcfb0 r6 : 00000000 r5 : c3ffcfb0 r4 : 02000000 r3 : c3ffcfd8 r2 : f2100000 r1 : f4000000 r0 : c3ffcfb0
Flags: Nzcv IRQs off FIQs off Mode SVC_32 ISA ARM Segment kernel
Control: 00007977 Table: a0004000 DAC: 00000017
Process swapper (pid: 0, stack limit = 0xc06201c8)
Stack: (0xc0621f04 to 0xc0622000)
1f00: c3ffcfd8 40000001 c3ffcfd8 c03ee08c c03da570 c03db90c c0637d24
1f20: 00000000 c03ec7cc c066e654 a0700000 000a0700 c03db914 c03db90c c03daf84 1f40: 00000000 000a0000 c0000000 c03ec7cc 000a0700 c0700000 ffff1000 000a3fff 1f60: 00001000 00000007 00000000 c03ec7cc c0008000 c03ed748 c0621fd4 c03d5d18 1f80: 69052d00 a03ec48c 00000000 c03d8ad0 0000006c 00007977 c036c6e8 00000001 1fa0: c0621fd4 c03ed744 c0628000 a0004000 69052d00 a03ec48c 00000000 c03d68d4 1fc0: 00000000 00000000 00000000 00000000 00000000 c03ed748 c0649894 c062801c 1fe0: c03ed744 c062b2f0 a0004000 69052d00 a03ec48c a0008040 00000000 00000000 [<c03e1100>] (vm_area_add_early) from [<c03d9ef4>] (add_static_vm_early+0xc/0x60) [<c03d9ef4>] (add_static_vm_early) from [<c03da570>] (iotable_init.part.6+0xa8/0xb4) [<c03da570>] (iotable_init.part.6) from [<c03db914>] (pxa25x_map_io+0x8/0x24) [<c03db914>] (pxa25x_map_io) from [<c03daf84>] (paging_init+0x744/0x8d8) [<c03daf84>] (paging_init) from [<c03d8ad0>] (setup_arch+0x354/0x608) [<c03d8ad0>] (setup_arch) from [<c03d68d4>] (start_kernel+0xa8/0x3dc) [<c03d68d4>] (start_kernel) from [<a0008040>] (0xa0008040)
Code: e5904008 e0811004 e1520001 2a000005 (e7f001f2) ---[ end trace f24b6c88ae00fa9a ]--- Kernel panic - not syncing: Attempted to kill the idle task! ---[ end Kernel panic - not syncing: Attempted to kill the idle task!
--- arch/arm/Kconfig.debug | 2 +- arch/arm/mach-pxa/include/mach/addr-map.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)
arch/arm/Kconfig.debug +1 -1
@@ -1142,7 +1142,7 @@ config DEBUG_UART_VIRT default 0xf1c28000 if DEBUG_SUNXI_UART0 default 0xf1c28400 if DEBUG_SUNXI_UART1 default 0xf1f02800 if DEBUG_SUNXI_R_UART - default 0xf2100000 if DEBUG_PXA_UART1 + default 0xf6200000 if DEBUG_PXA_UART1 default 0xf4090000 if ARCH_LPC32XX default 0xf4200000 if ARCH_GEMINI default 0xf7000000 if DEBUG_S3C24XX_UART && (DEBUG_S3C_UART0 || \
arch/arm/mach-pxa/include/mach/addr-map.h +5 -0
@@ -39,6 +39,11 @@#define DMEMC_SIZE 0x00100000/* +* Reserved space for low level debug virtual addresses within +* 0xf6200000..0xf6201000 +*/ + +/* * Internal Memory Controller (PXA27x and later) */ #define IMEMC_PHYS 0x58000000
Greg Kroah-Hartman
maintainerPATCH 299/319 powerpc: use device_online/offline() instead of cpu_up/down()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Streetman <[email protected]>
commit 10ccaf178b2b961d8bca252d647ed7ed8aae2a20 upstream.
In powerpc pseries platform dlpar operations, use device_online() and device_offline() instead of cpu_up() and cpu_down().
Calling cpu_up/down() directly does not update the cpu device offline field, which is used to online/offline a cpu from sysfs. Calling device_online/offline() instead keeps the sysfs cpu online value correct. The hotplug lock, which is required to be held when calling device_online/offline(), is already held when dlpar_online/offline_cpu() are called, since they are called only from cpu_probe|release_store().
This patch fixes errors on phyp (PowerVM) systems that have cpu(s) added/removed using dlpar operations; without this patch, the /sys/devices/system/cpu/cpuN/online nodes do not correctly show the online state of added/removed cpus.
--- arch/powerpc/platforms/pseries/dlpar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/dlpar.c +2 -2
@@ -379,7 +379,7 @@ static int dlpar_online_cpu(struct devicBUG_ON (get_cpu_current_state (cpu) !=CPU_STATE_OFFLINE );cpu_maps_update_done (); - rc =cpu_up (cpu); + rc =device_online (get_cpu_device (cpu));if (rc) goto out;cpu_maps_update_begin ();
@@ -462,7 +462,7 @@ static int dlpar_offline_cpu(struct deviif (get_cpu_current_state (cpu) ==CPU_STATE_ONLINE ) {set_preferred_offline_state (cpu,CPU_STATE_OFFLINE );cpu_maps_update_done (); - rc =cpu_down (cpu); + rc =device_offline (get_cpu_device (cpu));if (rc) goto out;cpu_maps_update_begin ();
Greg Kroah-Hartman
maintainerPATCH 300/319 powerpc/powernv: Properly fix LPC debugfs endianness
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Herrenschmidt <[email protected]>
commit 325e4114043469e5f9923d902b4d30bcc2be8163 upstream.
Endian is hard, especially when I designed a stupid FW interface, and I should know better... oh well, this is attempt #2 at fixing this properly. This time it seems to work with all access sizes and I can run my flashing tool (which exercises all sort of access sizes and types to access the SPI controller in the BMC) just fine.
--- arch/powerpc/platforms/powernv/opal-lpc.c | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
arch/powerpc/platforms/powernv/opal-lpc.c +59 -0
@@ -216,14 +216,54 @@ static ssize_t lpc_debug_read(struct fil &data, len);if (rc)return -ENXIO ; + +/* +* Now there is some trickery with the data returned by OPAL +* as it's the desired data right justified in a 32-bit BE +* word. +* +* This is a very bad interface and I'm to blame for it :-( +* +* So we can't just apply a 32-bit swap to what comes from OPAL, +* because user space expects the *bytes* to be in their proper +* respective positions (ie, LPC position). +* +* So what we really want to do here is to shift data right +* appropriately on a LE kernel. +* +* IE. If the LPC transaction has bytes B0, B1, B2 and B3 in that +* order, we have in memory written to by OPAL at the "data" +* pointer: +* +* Bytes: OPAL "data" LE "data" +* 32-bit: B0 B1 B2 B3 B0B1B2B3 B3B2B1B0 +* 16-bit: B0 B1 0000B0B1 B1B00000 +* 8-bit: B0 000000B0 B0000000 +* +* So a BE kernel will have the leftmost of the above in the MSB +* and rightmost in the LSB and can just then "cast" the u32 "data" +* down to the appropriate quantity and write it. +* +* However, an LE kernel can't. It doesn't need to swap because a +* load from data followed by a store to user are going to preserve +* the byte ordering which is the wire byte order which is what the +* user wants, but in order to "crop" to the right size, we need to +* shift right first. +*/ switch (len) {case 4 : rc =__put_user ((u32 )data, (u32 __user *)ubuf);break ;case 2 : +#ifdef __LITTLE_ENDIAN__ + data >>=16 ; +#endif rc =__put_user ((u16 )data, (u16 __user *)ubuf);break ;default : +#ifdef __LITTLE_ENDIAN__ + data >>=24 ; +#endif rc =__put_user ((u8 )data, (u8 __user *)ubuf);break ; }
@@ -263,12 +303,31 @@ static ssize_t lpc_debug_write(struct fielse if (todo >1 && (pos &1 ) ==0 ) len =2 ; } + +/* +* Similarly to the read case, we have some trickery here but +* it's different to handle. We need to pass the value to OPAL in +* a register whose layout depends on the access size. We want +* to reproduce the memory layout of the user, however we aren't +* doing a load from user and a store to another memory location +* which would achieve that. Here we pass the value to OPAL via +* a register which is expected to contain the "BE" interpretation +* of the byte sequence. IE: for a 32-bit access, byte 0 should be +* in the MSB. So here we *do* need to byteswap on LE. +* +* User bytes: LE "data" OPAL "data" +* 32-bit: B0 B1 B2 B3 B3B2B1B0 B0B1B2B3 +* 16-bit: B0 B1 0000B1B0 0000B0B1 +* 8-bit: B0 000000B0 000000B0 +*/ switch (len) {case 4 : rc =__get_user (data, (u32 __user *)ubuf); + data =cpu_to_be32 (data);break ;case 2 : rc =__get_user (data, (u16 __user *)ubuf); + data =cpu_to_be16 (data);break ;default : rc =__get_user (data, (u8 __user *)ubuf);
Greg Kroah-Hartman
maintainerPATCH 301/319 powerpc: do_notify_resume can be called with bad thread_info flags argument
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anton Blanchard <[email protected]>
commit 808be31426af57af22268ef0fcb42617beb3d15b upstream.
Back in 7230c5644188 ("powerpc: Rework lazy-interrupt handling") we added a call out to restore_interrupts() (written in c) before calling do_notify_resume:
bl restore_interrupts
addi r3,r1,STACK_FRAME_OVERHEAD
bl do_notify_resumeUnfortunately do_notify_resume takes two arguments, the second one being the thread_info flags:
void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
We do populate r4 (the second argument) earlier, but restore_interrupts() is free to muck it up all it wants. My guess is the gcc compiler gods shone down on us and its register allocator never used r4. Sometimes, rarely, luck is on our side.
LLVM on the other hand did trample r4.
--- arch/powerpc/kernel/entry_64.S | 6 ++++++ 1 file changed, 6 insertions(+)
arch/powerpc/kernel/entry_64.S +6 -0
@@ -659,7 +659,13 @@ _GLOBAL(ret_from_except_lite) 3: #endif bl save_nvgprs + /* + * Use a non volatile GPR to save and restore our thread_info flags + * across the call to restore_interrupts. + */ + mr r30,r4 bl restore_interrupts + mr r4,r30 addi r3,r1,STACK_FRAME_OVERHEAD bl do_notify_resume b ret_from_except
Greg Kroah-Hartman
maintainerPATCH 302/319 ALSA: hda - fix mute led problem for three HP laptops
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Wang <[email protected]>
commit c922c4e87b9b5a3b50d4d17b96f189121430f511 upstream.
Without the fix, the mute led can't work on these three machines.
After apply this fix, these three machines will fall back on the led control quirk as below, and through testing, the mute led works very well.
PIN_QUIRK(0x10ec0282, 0x103c, "HP", ALC269_FIXUP_HP_LINE1_MIC1_LED,
ALC282_STANDARD_PINS,
{0x12, 0x90a60140},
...--- sound/pci/hda/patch_realtek.c | 3 --- 1 file changed, 3 deletions(-)
sound/pci/hda/patch_realtek.c +0 -3
@@ -5008,9 +5008,6 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x2224 ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ),SND_PCI_QUIRK (0x103c ,0x2225 ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ),SND_PCI_QUIRK (0x103c ,0x2246 ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ), -SND_PCI_QUIRK (0x103c ,0x2247 ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ), -SND_PCI_QUIRK (0x103c ,0x2248 ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ), -SND_PCI_QUIRK (0x103c ,0x2249 ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ),SND_PCI_QUIRK (0x103c ,0x2253 ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ),SND_PCI_QUIRK (0x103c ,0x2254 ,"HP" ,ALC269_FIXUP_HP_GPIO_MIC1_LED ), SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
Greg Kroah-Hartman
maintainerPATCH 303/319 regulator: max77693: Fix use of uninitialized regulator config
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit ca0c37a0b489bb14bf3e1549e7a8d0c9a17f4919 upstream.
Driver allocated on stack struct regulator_config but didn't initialize it fully. Few fields (driver_data, ena_gpio) were left untouched. This lead to using random ena_gpio values as GPIOs for max77693 regulators.
On occasion these values could match real GPIO numbers leading to interfering with other drivers and to unsuccessful enable/disable of regulator.
--- drivers/regulator/max77693.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/max77693.c +1 -1
@@ -227,7 +227,7 @@ static int max77693_pmic_probe(struct plstruct max77693_dev *iodev =dev_get_drvdata (pdev->dev.parent);struct max77693_regulator_data *rdata =NULL ;int num_rdata, i; -struct regulator_config config; +struct regulator_config config = { }; num_rdata =max77693_pmic_init_rdata (&pdev->dev, &rdata);if (!rdata || num_rdata <=0 ) {
Greg Kroah-Hartman
maintainerPATCH 304/319 irqchip: armada-370-xp: Fix MSI interrupt handling
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Jaszczyk <[email protected]>
commit 298dcb2dd0267d51e4f7c94a628cd0765a50ad75 upstream.
The MSI interrupts use the 16 high doorbells, which are notified by using IRQ1 of the main interrupt controller.
The MSI interrupts were handled correctly for Armada-XP and Armada-370 but not for Armada-375 and Armada-38x, which use chained handler for the MPIC.
This commit fixes that by checking proper interrupt number in chained handler for the MPIC.
--- drivers/irqchip/irq-armada-370-xp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-armada-370-xp.c +2 -2
@@ -417,9 +417,9 @@ static void armada_370_xp_mpic_handle_ca irqmap =readl_relaxed (per_cpu_int_base +ARMADA_375_PPI_CAUSE ); -if (irqmap &BIT (0 )) { +if (irqmap &BIT (1 )) {armada_370_xp_handle_msi_irq (NULL , true); - irqmap &= ~BIT (0 ); + irqmap &= ~BIT (1 ); }for_each_set_bit (irqn, &irqmap,BITS_PER_LONG ) {
Greg Kroah-Hartman
maintainerPATCH 305/319 irqchip: armada-370-xp: Fix MPIC interrupt handling
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Jaszczyk <[email protected]>
commit 758e8366754d3fa57da978fef9d2c652f7b55c02 upstream.
In both Armada-375 and Armada-38x MPIC interrupts should be identified by reading cause register multiplied by the interrupt mask.
A lack of above mentioned multiplication resulted in a bug, caused by the fact that in Armada-375 and Armada-38x some of the interrupts (e.g. network interrupts) can be handled either as a GIC or MPIC interrupts. Therefore during MPIC interrupts handling, cause register shows hits from interrupts even if they are masked for MPIC but unmasked for a GIC.
This resulted in 'bad IRQ' error, because masked MPIC interrupt without registered interrupt handler, was trying to be handled during interrupt handling procedure of some other unmasked MPIC interrupt (e.g. local timer irq).
This commit fixes that by ensuring that during MPIC interrupt handling only interrupts that are unmasked for MPIC are processed.
--- drivers/irqchip/irq-armada-370-xp.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/irqchip/irq-armada-370-xp.c +17 -6
@@ -43,6 +43,7 @@#define ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS (0x34)#define ARMADA_370_XP_INT_SOURCE_CTL (irq) (0x100 + irq*4)#define ARMADA_370_XP_INT_SOURCE_CPU_MASK 0xF +#define ARMADA_370_XP_INT_IRQ_FIQ_MASK (cpuid) ((BIT(0) | BIT(8)) << cpuid)#define ARMADA_370_XP_CPU_INTACK_OFFS (0x44)#define ARMADA_375_PPI_CAUSE (0x10)
@@ -410,19 +411,29 @@ static void armada_370_xp_mpic_handle_ca struct irq_desc *desc) {struct irq_chip *chip =irq_get_chip (irq); -unsigned long irqmap, irqn; +unsigned long irqmap, irqn, irqsrc, cpuid;unsigned int cascade_irq;chained_irq_enter (chip, desc); irqmap =readl_relaxed (per_cpu_int_base +ARMADA_375_PPI_CAUSE ); - -if (irqmap &BIT (1 )) { -armada_370_xp_handle_msi_irq (NULL , true); - irqmap &= ~BIT (1 ); - } + cpuid =cpu_logical_map (smp_processor_id ());for_each_set_bit (irqn, &irqmap,BITS_PER_LONG ) { + irqsrc =readl_relaxed (main_int_base + +ARMADA_370_XP_INT_SOURCE_CTL (irqn)); + +/* Check if the interrupt is not masked on current CPU. +* Test IRQ (0-1) and FIQ (8-9) mask bits. +*/ +if (!(irqsrc &ARMADA_370_XP_INT_IRQ_FIQ_MASK (cpuid))) +continue ; + +if (irqn ==1 ) { +armada_370_xp_handle_msi_irq (NULL , true); +continue ; + } + cascade_irq =irq_find_mapping (armada_370_xp_mpic_domain, irqn);generic_handle_irq (cascade_irq); }
Greg Kroah-Hartman
maintainerPATCH 306/319 i2c: at91: dont account as iowait
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
commit 11cfbfb098b22d3e57f1f2be217cad20e2d48463 upstream.
iowait is for blkio [1]. I2C shouldn't use it.
[1] https://lkml.org/lkml/2014/11/3/317
--- drivers/i2c/busses/i2c-at91.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-at91.c +1 -1
@@ -434,7 +434,7 @@ static int at91_do_twi_transfer(struct a } } - ret =wait_for_completion_io_timeout (&dev->cmd_complete, + ret =wait_for_completion_timeout (&dev->cmd_complete, dev->adapter.timeout);if (ret ==0 ) {dev_err (dev->dev,"controller timed out\n" );
Greg Kroah-Hartman
maintainerPATCH 307/319 sysfs: driver core: Fix glue dir race condition by gdp_mutex
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yijing Wang <[email protected]>
commit e4a60d139060975eb956717e4f63ae348d4d8cc5 upstream.
There is a race condition when removing glue directory. It can be reproduced in following test:
path 1: Add first child devicedevice_add()
get_device_parent()
/*find parent from glue_dirs.list*/
list_for_each_entry(k, &dev->class->p->glue_dirs.list, entry)
if (k->parent == parent_kobj) {
kobj = kobject_get(k);
break;
}
....
class_dir_create_and_add()path2: Remove last child device under glue dir device_del()
cleanup_device_parent()
cleanup_glue_dir()
kobject_put(glue_dir);If path2 has been called cleanup_glue_dir(), but not call kobject_put(glue_dir), the glue dir is still in parent's kset list. Meanwhile, path1 find the glue dir from the glue_dirs.list. Path2 may release glue dir before path1 call kobject_get(). So kernel will report the warning and bug_on.
This is a "classic" problem we have of a kref in a list that can be found while the last instance could be removed at the same time.
This patch reuse gdp_mutex to fix this race condition.
The following calltrace is captured in kernel 3.4, but the latest kernel still has this bug.
-----------------------------------------------------
<4>[ 3965.441471] WARNING: at ...include/linux/kref.h:41 kobject_get+0x33/0x40() <4>[ 3965.441474] Hardware name: Romley <4>[ 3965.441475] Modules linked in: isd_iop(O) isd_xda(O)... ... <4>[ 3965.441605] Call Trace: <4>[ 3965.441611] [<ffffffff8103717a>] warn_slowpath_common+0x7a/0xb0 <4>[ 3965.441615] [<ffffffff810371c5>] warn_slowpath_null+0x15/0x20 <4>[ 3965.441618] [<ffffffff81215963>] kobject_get+0x33/0x40 <4>[ 3965.441624] [<ffffffff812d1e45>] get_device_parent.isra.11+0x135/0x1f0 <4>[ 3965.441627] [<ffffffff812d22d4>] device_add+0xd4/0x6d0 <4>[ 3965.441631] [<ffffffff812d0dbc>] ? dev_set_name+0x3c/0x40 .... <2>[ 3965.441912] kernel BUG at ..../fs/sysfs/group.c:65! <4>[ 3965.441915] invalid opcode: 0000 [#1] SMP ... <4>[ 3965.686743] [<ffffffff811a677e>] sysfs_create_group+0xe/0x10 <4>[ 3965.686748] [<ffffffff810cfb04>] blk_trace_init_sysfs+0x14/0x20 <4>[ 3965.686753] [<ffffffff811fcabb>] blk_register_queue+0x3b/0x120 <4>[ 3965.686756] [<ffffffff812030bc>] add_disk+0x1cc/0x490
....
-------------------------------------------------------
--- drivers/base/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/base/core.c +3 -1
@@ -724,12 +724,12 @@ class_dir_create_and_add(struct class *creturn &dir->kobj; } +static DEFINE_MUTEX (gdp_mutex);static struct kobject *get_device_parent (struct device *dev,struct device *parent) {if (dev->class) { -static DEFINE_MUTEX (gdp_mutex);struct kobject *kobj =NULL ;struct kobject *parent_kobj;struct kobject *k;
@@ -793,7 +793,9 @@ static void cleanup_glue_dir(struct devi glue_dir->kset != &dev->class->p->glue_dirs) return; +mutex_lock (&gdp_mutex);kobject_put (glue_dir); +mutex_unlock (&gdp_mutex); }static void cleanup_device_parent (struct device *dev)
Greg Kroah-Hartman
maintainerPATCH 309/319 of: Fix overflow bug in string property parsing functions
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grant Likely <[email protected]>
commit a87fa1d81a9fb5e9adca9820e16008c40ad09f33 upstream.
The string property read helpers will run off the end of the buffer if it is handed a malformed string property. Rework the parsers to make sure that doesn't happen. At the same time add new test cases to make sure the functions behave themselves.
The original implementations of of_property_read_string_index() and of_property_count_strings() both open-coded the same block of parsing code, each with it's own subtly different bugs. The fix here merges functions into a single helper and makes the original functions static inline wrappers around the helper.
One non-bugfix aspect of this patch is the addition of a new wrapper, of_property_read_string_array(). The new wrapper is needed by the device_properties feature that Rafael is working on and planning to merge for v3.19. The implementation is identical both with and without the new static inline wrapper, so it just got left in to reduce the churn on the header file.
--- drivers/of/base.c | 88 +++++++--------------------- drivers/of/selftest.c | 66 +++++++++++++++++++-- drivers/of/testcase-data/tests-phandle.dtsi | 2 include/linux/of.h | 84 ++++++++++++++++++++++---- 4 files changed, 154 insertions(+), 86 deletions(-)
drivers/of/base.c +22 -66
@@ -1277,52 +1277,6 @@ int of_property_read_string(struct devicEXPORT_SYMBOL_GPL (of_property_read_string);/** -* of_property_read_string_index - Find and read a string from a multiple -* strings property. -* @np: device node from which the property value is to be read. -* @propname: name of the property to be searched. -* @index: index of the string in the list of strings -* @out_string: pointer to null terminated return string, modified only if -* return value is 0. -* -* Search for a property in a device tree node and retrieve a null -* terminated string value (pointer to data, not a copy) in the list of strings -* contained in that property. -* Returns 0 on success, -EINVAL if the property does not exist, -ENODATA if -* property does not have a value, and -EILSEQ if the string is not -* null-terminated within the length of the property data. -* -* The out_string pointer is modified only if a valid string can be decoded. -*/ -int of_property_read_string_index (struct device_node *np,const char *propname, -int index,const char **output) -{ -struct property *prop =of_find_property (np, propname,NULL ); -int i =0 ; -size_t l =0 , total =0 ; -const char *p; - -if (!prop) -return -EINVAL ; -if (!prop->value) -return -ENODATA ; -if (strnlen (prop->value, prop->length) >= prop->length) -return -EILSEQ ; - - p = prop->value; - -for (i =0 ; total < prop->length; total += l, p += l) { - l =strlen (p) +1 ; -if (i++ == index) { - *output = p; -return 0 ; - } - } -return -ENODATA ; -} -EXPORT_SYMBOL_GPL (of_property_read_string_index); - -/** * of_property_match_string() - Find string in a list and return index * @np: pointer to node containing string list property * @propname: string list property name
@@ -1348,7 +1302,7 @@ int of_property_match_string(struct devi end = p + prop->length;for (i =0 ; p < end; i++, p += l) { - l =strlen (p) +1 ; + l =strnlen (p, end - p) +1 ;if (p + l > end)return -EILSEQ ;pr_debug ("comparing %s with %s\n" , string, p);
@@ -1360,39 +1314,41 @@ int of_property_match_string(struct deviEXPORT_SYMBOL_GPL (of_property_match_string);/** -* of_property_count_strings - Find and return the number of strings from a -* multiple strings property. +* of_property_read_string_util() - Utility helper for parsing string properties * @np: device node from which the property value is to be read. * @propname: name of the property to be searched. +* @out_strs: output array of string pointers. +* @sz: number of array elements to read. +* @skip: Number of strings to skip over at beginning of list. * -* Search for a property in a device tree node and retrieve the number of null -* terminated string contain in it. Returns the number of strings on -* success, -EINVAL if the property does not exist, -ENODATA if property -* does not have a value, and -EILSEQ if the string is not null-terminated -* within the length of the property data. +* Don't call this function directly. It is a utility helper for the +* of_property_read_string*() family of functions. */ -int of_property_count_strings (struct device_node *np,const char *propname) +int of_property_read_string_helper (struct device_node *np,const char *propname, +const char **out_strs,size_t sz,int skip) {struct property *prop =of_find_property (np, propname,NULL ); -int i =0 ; -size_t l =0 , total =0 ; -const char *p; +int l =0 , i =0 ; +const char *p, *end;if (!prop)return -EINVAL ;if (!prop->value)return -ENODATA ; -if (strnlen (prop->value, prop->length) >= prop->length) -return -EILSEQ ; - p = prop->value; + end = p + prop->length; -for (i =0 ; total < prop->length; total += l, p += l, i++) - l =strlen (p) +1 ; - -return i; +for (i =0 ; p < end && (!out_strs || i < skip + sz); i++, p += l) { + l =strnlen (p, end - p) +1 ; +if (p + l > end) +return -EILSEQ ; +if (out_strs && i >= skip) + *out_strs++ = p; + } + i -= skip; +return i <=0 ? -ENODATA : i; } -EXPORT_SYMBOL_GPL (of_property_count_strings); +EXPORT_SYMBOL_GPL (of_property_read_string_helper);void of_print_phandle_args (const char *msg,const struct of_phandle_args *args) {
drivers/of/selftest.c +60 -6
88 lines not on this page · raw message
drivers/of/testcase-data/tests-phandle.dtsi +2 -0
@@ -39,7 +39,9 @@ phandle-list-bad-args = <&provider2 1 0>, <&provider3 0>; empty-property; + string-property = "foobar"; unterminated-string = [40 41 42 43]; + unterminated-string-list = "first", "second", [40 41 42 43]; }; }; };
include/linux/of.h +70 -14
105 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 310/319 Btrfs: fix kfree on list_head in btrfs_lookup_csums_range error cleanup
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
commit 6e5aafb27419f32575b27ef9d6a31e5d54661aca upstream.
If we hit any errors in btrfs_lookup_csums_range, we'll loop through all the csums we allocate and free them. But the code was using list_entry incorrectly, and ended up trying to free the on-stack list_head instead.
This bug came from commit 0678b6185
btrfs: Don't BUG_ON kzalloc error in btrfs_lookup_csums_range()
--- fs/btrfs/file-item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/file-item.c +1 -1
@@ -423,7 +423,7 @@ int btrfs_lookup_csums_range(struct btrf ret =0 ; fail:while (ret <0 && !list_empty (&tmplist)) { - sums = list_entry(&tmplist, struct btrfs_ordered_sum, list); + sums = list_entry(tmplist.next, struct btrfs_ordered_sum, list);list_del (&sums->list);kfree (sums); }
Greg Kroah-Hartman
maintainerPATCH 311/319 xfs: bulkstat doesnt release AGI buffer on error
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit a6bbce54efa9145dbcf3029c885549f7ebc40a3b upstream.
The recent refactoring of the bulkstat code left a small landmine in the code. If a inobt read fails, then the tree walk is aborted and returns without releasing the AGI buffer or freeing the cursor. This can lead to a subsequent bulkstat call hanging trying to grab the AGI buffer again.
--- fs/xfs/xfs_itable.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
fs/xfs/xfs_itable.c +10 -6
@@ -427,7 +427,7 @@ xfs_bulkstat( error =xfs_bulkstat_grab_ichunk (cur, agino, &icount, &r);if (error) -break ; + goto del_cursor;if (icount) { irbp->ir_startino = r.ir_startino; irbp->ir_freecount = r.ir_freecount;
@@ -442,7 +442,7 @@ xfs_bulkstat( error =xfs_inobt_lookup (cur,0 ,XFS_LOOKUP_GE , &tmp); }if (error) -break ; + goto del_cursor;/* * Loop through inode btree records in this ag,
@@ -454,7 +454,7 @@ xfs_bulkstat( error =xfs_inobt_get_rec (cur, &r, &i);if (error || i ==0 ) { end_of_ag =1 ; -break ; + goto del_cursor; }/*
@@ -476,13 +476,17 @@ xfs_bulkstat( error =xfs_btree_increment (cur,0 , &tmp);cond_resched (); } +/* -* Drop the btree buffers and the agi buffer. -* We can't hold any of the locks these represent -* when calling iget. +* Drop the btree buffers and the agi buffer as we can't hold any +* of the locks these represent when calling iget. If there is a +* pending error, then we are done. */ +del_cursor:xfs_btree_del_cursor (cur,XFS_BTREE_NOERROR );xfs_buf_relse (agbp); +if (error) +break ;/* * Now format all the good inodes into the user's buffer. */
Greg Kroah-Hartman
maintainerPATCH 312/319 xfs: Check error during inode btree iteration in xfs_bulkstat()
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 7a19dee116c8fae7ba7a778043c245194289f5a2 upstream.
xfs_bulkstat() doesn't check error return from xfs_btree_increment(). In case of specific fs corruption that could result in xfs_bulkstat() entering an infinite loop because we would be looping over the same chunk over and over again. Fix the problem by checking the return value and terminating the loop properly.
Coverity-id: 1231338
--- fs/xfs/xfs_itable.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/xfs/xfs_itable.c +4 -0
@@ -474,6 +474,10 @@ xfs_bulkstat(*/ agino = r.ir_startino +XFS_INODES_PER_CHUNK ; error =xfs_btree_increment (cur,0 , &tmp); +if (error) { + end_of_ag =1 ; + goto del_cursor; + }cond_resched (); }
Greg Kroah-Hartman
maintainerPATCH 313/319 xfs: bulkstat btree walk doesnt terminate
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit afa947cb52a8e73fe71915a0b0af6fcf98dfbe1a upstream.
The bulkstat code has several different ways of detecting the end of an AG when doing a walk. They are not consistently detected, and the code that checks for the end of AG conditions is not consistently coded. Hence the are conditions where the walk code can get stuck in an endless loop making no progress and not triggering any termination conditions.
Convert all the "tmp/i" status return codes from btree operations to a common name (stat) and apply end-of-ag detection to these operations consistently.
--- fs/xfs/xfs_itable.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
fs/xfs/xfs_itable.c +10 -9
@@ -356,7 +356,6 @@ xfs_bulkstat(int end_of_ag;/* set if we've seen the ag end */ int error;/* error code */ int fmterror;/* bulkstat formatter result */ -int i;/* loop index */ int icount;/* count of inodes good in irbuf */ size_t irbsize;/* size of irec buffer in bytes */ xfs_ino_t ino;/* inode number (filesystem) */
@@ -366,11 +365,11 @@ xfs_bulkstat(xfs_ino_t lastino;/* last inode number returned */ int nirbuf;/* size of irbuf */ int rval;/* return value error code */ -int tmp;/* result value from btree calls */ int ubcount;/* size of user's buffer */ int ubleft;/* bytes left in user's buffer */ char __user *ubufp;/* pointer into user's buffer */ int ubelem;/* spaces used in user's buffer */ +int stat;/* * Get the last inode value, see if there's nothing to do.
@@ -436,13 +435,15 @@ xfs_bulkstat( agino = r.ir_startino +XFS_INODES_PER_CHUNK ; }/* Increment to the next record */ - error =xfs_btree_increment (cur,0 , &tmp); + error =xfs_btree_increment (cur,0 , &stat); }else {/* Start of ag. Lookup the first inode chunk */ - error =xfs_inobt_lookup (cur,0 ,XFS_LOOKUP_GE , &tmp); + error =xfs_inobt_lookup (cur,0 ,XFS_LOOKUP_GE , &stat); } -if (error) +if (error || stat ==0 ) { + end_of_ag =1 ; goto del_cursor; + }/* * Loop through inode btree records in this ag,
@@ -451,8 +452,8 @@ xfs_bulkstat(while (irbp < irbufend && icount < ubcount) {struct xfs_inobt_rec_incore r; - error =xfs_inobt_get_rec (cur, &r, &i); -if (error || i ==0 ) { + error =xfs_inobt_get_rec (cur, &r, &stat); +if (error || stat ==0 ) { end_of_ag =1 ; goto del_cursor; }
@@ -473,8 +474,8 @@ xfs_bulkstat(* Set agino to after this chunk and bump the cursor. */ agino = r.ir_startino +XFS_INODES_PER_CHUNK ; - error =xfs_btree_increment (cur,0 , &tmp); -if (error) { + error =xfs_btree_increment (cur,0 , &stat); +if (error || stat ==0 ) { end_of_ag =1 ; goto del_cursor; }
Greg Kroah-Hartman
maintainerPATCH 314/319 xfs: bulkstat chunk formatting cursor is broken
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit bf4a5af20d25ecc8876978ad34b8db83b4235f3c upstream.
The xfs_bulkstat_agichunk formatting cursor takes buffer values from the main loop and passes them via the structure to the chunk formatter, and the writes the changed values back into the main loop local variables. Unfortunately, this complex dance is full of corner cases that aren't handled correctly.
The biggest problem is that it is double handling the information in both the main loop and the chunk formatting function, leading to inconsistent updates and endless loops where progress is not made.
To fix this, push the struct xfs_bulkstat_agichunk outwards to be the primary holder of user buffer information. this removes the double handling in the main loop.
Also, pass the last inode processed by the chunk formatter as a separate parameter as it purely an output variable and is not related to the user buffer consumption cursor.
Finally, the chunk formatting code is not shared by anyone, so make it local to xfs_itable.c.
--- fs/xfs/xfs_itable.c | 59 ++++++++++++++++++++++++---------------------------- fs/xfs/xfs_itable.h | 16 -------------- 2 files changed, 28 insertions(+), 47 deletions(-)
fs/xfs/xfs_itable.c +28 -31
@@ -262,20 +262,26 @@ xfs_bulkstat_grab_ichunk(#define XFS_BULKSTAT_UBLEFT (ubleft) ((ubleft) >= statstruct_size) +struct xfs_bulkstat_agichunk { +char __user **ac_ubuffer;/* pointer into user's buffer */ +int ac_ubleft;/* bytes left in user's buffer */ +int ac_ubelem;/* spaces used in user's buffer */ +}; +/* * Process inodes in chunk with a pointer to a formatter function * that will iget the inode and fill in the appropriate structure. */ -int +static int xfs_bulkstat_ag_ichunk (struct xfs_mount *mp,xfs_agnumber_t agno,struct xfs_inobt_rec_incore *irbp,bulkstat_one_pf formatter,size_t statstruct_size, -struct xfs_bulkstat_agichunk *acp) +struct xfs_bulkstat_agichunk *acp, +xfs_ino_t *lastino) { -xfs_ino_t lastino = acp->ac_lastino;char __user **ubufp = acp->ac_ubuffer;int ubleft = acp->ac_ubleft;int ubelem = acp->ac_ubelem;
@@ -295,7 +301,7 @@ xfs_bulkstat_ag_ichunk(/* Skip if this inode is free */ if (XFS_INOBT_MASK (chunkidx) & irbp->ir_free) { - lastino = ino; + *lastino = ino;continue ; }
@@ -313,7 +319,7 @@ xfs_bulkstat_ag_ichunk( ubleft =0 ;break ; } - lastino = ino; + *lastino = ino;continue ; }if (fmterror ==BULKSTAT_RV_GIVEUP ) {
@@ -325,10 +331,9 @@ xfs_bulkstat_ag_ichunk( *ubufp += ubused; ubleft -= ubused; ubelem++; - lastino = ino; + *lastino = ino; } - acp->ac_lastino = lastino; acp->ac_ubleft = ubleft; acp->ac_ubelem = ubelem;
@@ -355,7 +360,6 @@ xfs_bulkstat(xfs_btree_cur_t *cur;/* btree cursor for ialloc btree */ int end_of_ag;/* set if we've seen the ag end */ int error;/* error code */ -int fmterror;/* bulkstat formatter result */ int icount;/* count of inodes good in irbuf */ size_t irbsize;/* size of irec buffer in bytes */ xfs_ino_t ino;/* inode number (filesystem) */
@@ -366,10 +370,8 @@ xfs_bulkstat(int nirbuf;/* size of irbuf */ int rval;/* return value error code */ int ubcount;/* size of user's buffer */ -int ubleft;/* bytes left in user's buffer */ -char __user *ubufp;/* pointer into user's buffer */ -int ubelem;/* spaces used in user's buffer */ int stat; +struct xfs_bulkstat_agichunk ac;/* * Get the last inode value, see if there's nothing to do.
@@ -386,11 +388,13 @@ xfs_bulkstat( } ubcount = *ubcountp;/* statstruct's */ - ubleft = ubcount * statstruct_size;/* bytes */ - *ubcountp = ubelem =0 ; + ac.ac_ubuffer = &ubuffer; + ac.ac_ubleft = ubcount * statstruct_size;/* bytes */ ; + ac.ac_ubelem =0 ; + + *ubcountp =0 ; *done =0 ; - fmterror =0 ; - ubufp = ubuffer; + irbuf =kmem_zalloc_greedy (&irbsize,PAGE_SIZE ,PAGE_SIZE *4 );if (!irbuf)return -ENOMEM ;
@@ -402,7 +406,7 @@ xfs_bulkstat(* inode returned; 0 means start of the allocation group. */ rval =0 ; -while (XFS_BULKSTAT_UBLEFT (ubleft) && agno < mp->m_sb.sb_agcount) { +while (XFS_BULKSTAT_UBLEFT (ac.ac_ubleft) && agno < mp->m_sb.sb_agcount) {cond_resched (); error =xfs_ialloc_read_agi (mp,NULL , agno, &agbp);if (error)
@@ -497,28 +501,21 @@ del_cursor:*/ irbufend = irbp;for (irbp = irbuf; - irbp < irbufend &&XFS_BULKSTAT_UBLEFT (ubleft); irbp++) { -struct xfs_bulkstat_agichunk ac; - - ac.ac_lastino = lastino; - ac.ac_ubuffer = &ubuffer; - ac.ac_ubleft = ubleft; - ac.ac_ubelem = ubelem; + irbp < irbufend &&XFS_BULKSTAT_UBLEFT (ac.ac_ubleft); + irbp++) { error =xfs_bulkstat_ag_ichunk (mp, agno, irbp, - formatter, statstruct_size, &ac); + formatter, statstruct_size, &ac, + &lastino);if (error) rval = error; - lastino = ac.ac_lastino; - ubleft = ac.ac_ubleft; - ubelem = ac.ac_ubelem; -cond_resched (); } +/* * Set up for the next loop iteration. */ -if (XFS_BULKSTAT_UBLEFT (ubleft)) { +if (XFS_BULKSTAT_UBLEFT (ac.ac_ubleft)) {if (end_of_ag) { agno++; agino =0 ;
@@ -531,11 +528,11 @@ del_cursor:* Done, we're either out of filesystem or space to put the data. */ kmem_free (irbuf); - *ubcountp = ubelem; + *ubcountp = ac.ac_ubelem;/* * Found some inodes, return them now and return the error next time. */ -if (ubelem) +if (ac.ac_ubelem) rval =0 ;if (agno >= mp->m_sb.sb_agcount) {/*
fs/xfs/xfs_itable.h +0 -16
@@ -30,22 +30,6 @@ typedef int (*bulkstat_one_pf)(struct xfint *ubused, int *stat); -struct xfs_bulkstat_agichunk { -xfs_ino_t ac_lastino;/* last inode returned */ -char __user **ac_ubuffer;/* pointer into user's buffer */ -int ac_ubleft;/* bytes left in user's buffer */ -int ac_ubelem;/* spaces used in user's buffer */ -}; - -int -xfs_bulkstat_ag_ichunk ( -struct xfs_mount *mp, -xfs_agnumber_t agno, -struct xfs_inobt_rec_incore *irbp, -bulkstat_one_pf formatter, -size_t statstruct_size, -struct xfs_bulkstat_agichunk *acp); -/* * Values for stat return value. */
Greg Kroah-Hartman
maintainerPATCH 315/319 xfs: bulkstat chunk-formatter has issues
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit 2b831ac6bc87d3cbcbb1a8816827b6923403e461 upstream.
The loop construct has issues:
- clustidx is completely unused, so remove it.
- the loop tries to be smart by terminating when the "freecount" tells it that all inodes are free. Just drop it as in most cases we have to scan all inodes in the chunk anyway.
- move the "user buffer left" condition check to the only point where we consume space int eh user buffer.
- move the initialisation of agino out of the loop, leaving just a simple loop control logic using the clusteridx.
Also, double handling of the user buffer variables leads to problems tracking the current state - use the cursor variables directly rather than keeping local copies and then having to update the cursor before returning.
--- fs/xfs/xfs_itable.c | 58 +++++++++++++++++++++------------------------------- 1 file changed, 24 insertions(+), 34 deletions(-)
fs/xfs/xfs_itable.c +24 -34
@@ -283,59 +283,49 @@ xfs_bulkstat_ag_ichunk( xfs_ino_t *lastino) {char __user **ubufp = acp->ac_ubuffer; -int ubleft = acp->ac_ubleft; -int ubelem = acp->ac_ubelem; -int chunkidx, clustidx; +int chunkidx;int error =0 ;xfs_agino_t agino; -for (agino = irbp->ir_startino, chunkidx = clustidx =0 ; -XFS_BULKSTAT_UBLEFT (ubleft) && - irbp->ir_freecount <XFS_INODES_PER_CHUNK ; - chunkidx++, clustidx++, agino++) { -int fmterror;/* bulkstat formatter result */ + agino = irbp->ir_startino; +for (chunkidx =0 ; chunkidx <XFS_INODES_PER_CHUNK ; + chunkidx++, agino++) { +int fmterror;int ubused;xfs_ino_t ino =XFS_AGINO_TO_INO (mp, agno, agino); -ASSERT (chunkidx <XFS_INODES_PER_CHUNK ); -/* Skip if this inode is free */ if (XFS_INOBT_MASK (chunkidx) & irbp->ir_free) { *lastino = ino;continue ; } -/* -* Count used inodes as free so we can tell when the -* chunk is used up. -*/ - irbp->ir_freecount++; -/* Get the inode and fill in a single buffer */ ubused = statstruct_size; - error =formatter (mp, ino, *ubufp, ubleft, &ubused, &fmterror); -if (fmterror ==BULKSTAT_RV_NOTHING ) { -if (error && error != -ENOENT && error != -EINVAL ) { - ubleft =0 ; -break ; - } - *lastino = ino; -continue ; - } -if (fmterror ==BULKSTAT_RV_GIVEUP ) { - ubleft =0 ; + error =formatter (mp, ino, *ubufp, acp->ac_ubleft, + &ubused, &fmterror); +if (fmterror ==BULKSTAT_RV_GIVEUP || + (error && error != -ENOENT && error != -EINVAL )) { + acp->ac_ubleft =0 ;ASSERT (error);break ; } -if (*ubufp) - *ubufp += ubused; - ubleft -= ubused; - ubelem++; + +/* be careful not to leak error if at end of chunk */ +if (fmterror ==BULKSTAT_RV_NOTHING || error) { + *lastino = ino; + error =0 ; +continue ; + } + + *ubufp += ubused; + acp->ac_ubleft -= ubused; + acp->ac_ubelem++; *lastino = ino; - } - acp->ac_ubleft = ubleft; - acp->ac_ubelem = ubelem; +if (acp->ac_ubleft < statstruct_size) +break ; + }return error; }
Greg Kroah-Hartman
maintainerPATCH 316/319 xfs: bulkstat main loop logic is a mess
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit 6e57c542cb7e0e580eb53ae76a77875c7d92b4b1 upstream.
There are a bunch of variables tha tare more wildy scoped than they need to be, obfuscated user buffer checks and tortured "next inode" tracking. This all needs cleaning up to expose the real issues that need fixing.
--- fs/xfs/xfs_itable.c | 56 ++++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 32 deletions(-)
fs/xfs/xfs_itable.c +24 -32
@@ -348,30 +348,23 @@ xfs_bulkstat(xfs_agino_t agino;/* inode # in allocation group */ xfs_agnumber_t agno;/* allocation group number */ xfs_btree_cur_t *cur;/* btree cursor for ialloc btree */ -int end_of_ag;/* set if we've seen the ag end */ -int error;/* error code */ -int icount;/* count of inodes good in irbuf */ size_t irbsize;/* size of irec buffer in bytes */ -xfs_ino_t ino;/* inode number (filesystem) */ -xfs_inobt_rec_incore_t *irbp;/* current irec buffer pointer */ xfs_inobt_rec_incore_t *irbuf;/* start of irec buffer */ -xfs_inobt_rec_incore_t *irbufend;/* end of good irec buffer entries */ xfs_ino_t lastino;/* last inode number returned */ int nirbuf;/* size of irbuf */ int rval;/* return value error code */ int ubcount;/* size of user's buffer */ -int stat;struct xfs_bulkstat_agichunk ac; +int error =0 ;/* * Get the last inode value, see if there's nothing to do. */ - ino = (xfs_ino_t)*lastinop; - lastino = ino; - agno =XFS_INO_TO_AGNO (mp, ino); - agino =XFS_INO_TO_AGINO (mp, ino); + lastino = *lastinop; + agno =XFS_INO_TO_AGNO (mp, lastino); + agino =XFS_INO_TO_AGINO (mp, lastino);if (agno >= mp->m_sb.sb_agcount || - ino !=XFS_AGINO_TO_INO (mp, agno, agino)) { + lastino !=XFS_AGINO_TO_INO (mp, agno, agino)) { *done =1 ; *ubcountp =0 ;return 0 ;
@@ -396,8 +389,13 @@ xfs_bulkstat(* inode returned; 0 means start of the allocation group. */ rval =0 ; -while (XFS_BULKSTAT_UBLEFT (ac.ac_ubleft) && agno < mp->m_sb.sb_agcount) { -cond_resched (); +while (agno < mp->m_sb.sb_agcount) { +struct xfs_inobt_rec_incore *irbp = irbuf; +struct xfs_inobt_rec_incore *irbufend = irbuf + nirbuf; +bool end_of_ag = false; +int icount =0 ; +int stat; + error =xfs_ialloc_read_agi (mp,NULL , agno, &agbp);if (error)break ;
@@ -407,10 +405,6 @@ xfs_bulkstat(*/ cur =xfs_inobt_init_cursor (mp,NULL , agbp, agno,XFS_BTNUM_INO ); - irbp = irbuf; - irbufend = irbuf + nirbuf; - end_of_ag =0 ; - icount =0 ;if (agino >0 ) {/* * In the middle of an allocation group, we need to get
@@ -435,7 +429,7 @@ xfs_bulkstat( error =xfs_inobt_lookup (cur,0 ,XFS_LOOKUP_GE , &stat); }if (error || stat ==0 ) { - end_of_ag =1 ; + end_of_ag = true; goto del_cursor; }
@@ -448,7 +442,7 @@ xfs_bulkstat( error =xfs_inobt_get_rec (cur, &r, &stat);if (error || stat ==0 ) { - end_of_ag =1 ; + end_of_ag = true; goto del_cursor; }
@@ -470,7 +464,7 @@ xfs_bulkstat( agino = r.ir_startino +XFS_INODES_PER_CHUNK ; error =xfs_btree_increment (cur,0 , &stat);if (error || stat ==0 ) { - end_of_ag =1 ; + end_of_ag = true; goto del_cursor; }cond_resched ();
@@ -491,7 +485,7 @@ del_cursor:*/ irbufend = irbp;for (irbp = irbuf; - irbp < irbufend &&XFS_BULKSTAT_UBLEFT (ac.ac_ubleft); + irbp < irbufend && ac.ac_ubleft >= statstruct_size; irbp++) { error = xfs_bulkstat_ag_ichunk(mp, agno, irbp, formatter, statstruct_size, &ac,
@@ -502,17 +496,15 @@ del_cursor:cond_resched (); } -/* -* Set up for the next loop iteration. -*/ -if (XFS_BULKSTAT_UBLEFT (ac.ac_ubleft)) { -if (end_of_ag) { - agno++; - agino =0 ; - }else - agino =XFS_INO_TO_AGINO (mp, lastino); - }else +/* If we've run out of space, we are done */ +if (ac.ac_ubleft < statstruct_size)break ; + +if (end_of_ag) { + agno++; + agino =0 ; + }else + agino =XFS_INO_TO_AGINO (mp, lastino); }/* * Done, we're either out of filesystem or space to put the data.
Greg Kroah-Hartman
maintainerPATCH 317/319 xfs: bulkstat error handling is broken
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit febe3cbe38b0bc0a925906dc90e8d59048851f87 upstream.
The error propagation is a horror - xfs_bulkstat() returns a rval variable which is only set if there are formatter errors. Any sort of btree walk error or corruption will cause the bulkstat walk to terminate but will not pass an error back to userspace. Worse is the fact that formatter errors will also be ignored if any inodes were correctly formatted into the user buffer.
Hence bulkstat can fail badly yet still report success to userspace. This causes significant issues with xfsdump not dumping everything in the filesystem yet reporting success. It's not until a restore fails that there is any indication that the dump was bad and tha bulkstat failed. This patch now triggers xfsdump to fail with bulkstat errors rather than silently missing files in the dump.
This now causes bulkstat to fail when the lastino cookie does not fall inside an existing inode chunk. The pre-3.17 code tolerated that error by allowing the code to move to the next inode chunk as the agino target is guaranteed to fall into the next btree record.
With the fixes up to this point in the series, xfsdump now passes on the troublesome filesystem image that exposes all these bugs.
--- fs/xfs/xfs_itable.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
fs/xfs/xfs_itable.c +19 -10
@@ -236,8 +236,10 @@ xfs_bulkstat_grab_ichunk(XFS_WANT_CORRUPTED_RETURN (stat ==1 );/* Check if the record contains the inode in request */ -if (irec->ir_startino +XFS_INODES_PER_CHUNK <= agino) -return -EINVAL ; +if (irec->ir_startino +XFS_INODES_PER_CHUNK <= agino) { + *icount =0 ; +return 0 ; + } idx = agino - irec->ir_startino +1 ; if (idx < XFS_INODES_PER_CHUNK &&
@@ -352,7 +354,6 @@ xfs_bulkstat(xfs_inobt_rec_incore_t *irbuf;/* start of irec buffer */ xfs_ino_t lastino;/* last inode number returned */ int nirbuf;/* size of irbuf */ -int rval;/* return value error code */ int ubcount;/* size of user's buffer */ struct xfs_bulkstat_agichunk ac;int error =0 ;
@@ -388,7 +389,6 @@ xfs_bulkstat(* Loop over the allocation groups, starting from the last * inode returned; 0 means start of the allocation group. */ - rval =0 ;while (agno < mp->m_sb.sb_agcount) {struct xfs_inobt_rec_incore *irbp = irbuf;struct xfs_inobt_rec_incore *irbufend = irbuf + nirbuf;
@@ -491,13 +491,16 @@ del_cursor: formatter, statstruct_size, &ac, &lastino);if (error) - rval = error; +break ;cond_resched (); } -/* If we've run out of space, we are done */ -if (ac.ac_ubleft < statstruct_size) +/* +* If we've run out of space or had a formatting error, we +* are now done +*/ +if (ac.ac_ubleft < statstruct_size || error)break ;if (end_of_ag) {
@@ -511,11 +514,17 @@ del_cursor:*/ kmem_free (irbuf); *ubcountp = ac.ac_ubelem; +/* -* Found some inodes, return them now and return the error next time. +* We found some inodes, so clear the error status and return them. +* The lastino pointer will point directly at the inode that triggered +* any error that occurred, so on the next call the error will be +* triggered again and propagated to userspace as there will be no +* formatted inodes in the buffer. */ if (ac.ac_ubelem) - rval =0 ; + error =0 ; +if (agno >= mp->m_sb.sb_agcount) {/* * If we ran out of filesystem, mark lastino as off
@@ -527,7 +536,7 @@ del_cursor: }else *lastinop = (xfs_ino_t )lastino; -return rval; +return error; }int
Greg Kroah-Hartman
maintainerPATCH 318/319 xfs: track bulkstat progress by agino
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit 002758992693ae63c04122603ea9261a0a58d728 upstream.
The bulkstat main loop progress is tracked by the "lastino" variable, which is a full 64 bit inode. However, the loop actually works on agno/agino pairs, and so there's a significant disconnect between the rest of the loop and the main cursor. Convert this to use the agino, and pass the agino into the chunk formatting function and convert it too.
This gets rid of the inconsistency in the loop processing, and finally makes it simple for us to skip inodes at any point in the loop simply by incrementing the agino cursor.
--- fs/xfs/xfs_itable.c | 71 ++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 37 deletions(-)
fs/xfs/xfs_itable.c +34 -37
@@ -282,30 +282,31 @@ xfs_bulkstat_ag_ichunk(bulkstat_one_pf formatter, size_t statstruct_size, struct xfs_bulkstat_agichunk *acp, - xfs_ino_t *lastino) + xfs_agino_t *last_agino) { char __user **ubufp = acp->ac_ubuffer;int chunkidx;int error =0 ; -xfs_agino_t agino; +xfs_agino_t agino = irbp->ir_startino; - agino = irbp->ir_startino;for (chunkidx =0 ; chunkidx <XFS_INODES_PER_CHUNK ; chunkidx++, agino++) {int fmterror;int ubused; -xfs_ino_t ino =XFS_AGINO_TO_INO (mp, agno, agino); + +/* inode won't fit in buffer, we are done */ +if (acp->ac_ubleft < statstruct_size) +break ;/* Skip if this inode is free */ -if (XFS_INOBT_MASK (chunkidx) & irbp->ir_free) { - *lastino = ino; +if (XFS_INOBT_MASK (chunkidx) & irbp->ir_free)continue ; - }/* Get the inode and fill in a single buffer */ ubused = statstruct_size; - error =formatter (mp, ino, *ubufp, acp->ac_ubleft, - &ubused, &fmterror); + error =formatter (mp,XFS_AGINO_TO_INO (mp, agno, agino), + *ubufp, acp->ac_ubleft, &ubused, &fmterror); +if (fmterror ==BULKSTAT_RV_GIVEUP || (error && error != -ENOENT && error != -EINVAL )) { acp->ac_ubleft =0 ;
@@ -315,7 +316,6 @@ xfs_bulkstat_ag_ichunk(/* be careful not to leak error if at end of chunk */ if (fmterror ==BULKSTAT_RV_NOTHING || error) { - *lastino = ino; error =0 ;continue ; }
@@ -323,12 +323,18 @@ xfs_bulkstat_ag_ichunk( *ubufp += ubused; acp->ac_ubleft -= ubused; acp->ac_ubelem++; - *lastino = ino; - -if (acp->ac_ubleft < statstruct_size) -break ; } +/* +* Post-update *last_agino. At this point, agino will always point one +* inode past the last inode we processed successfully. Hence we +* substract that inode when setting the *last_agino cursor so that we +* return the correct cookie to userspace. On the next bulkstat call, +* the inode under the lastino cookie will be skipped as we have already +* processed it here. +*/ + *last_agino = agino -1 ; +return error; }
@@ -352,7 +358,6 @@ xfs_bulkstat(xfs_btree_cur_t *cur;/* btree cursor for ialloc btree */ size_t irbsize;/* size of irec buffer in bytes */ xfs_inobt_rec_incore_t *irbuf;/* start of irec buffer */ -xfs_ino_t lastino;/* last inode number returned */ int nirbuf;/* size of irbuf */ int ubcount;/* size of user's buffer */ struct xfs_bulkstat_agichunk ac;
@@ -361,11 +366,10 @@ xfs_bulkstat(/* * Get the last inode value, see if there's nothing to do. */ - lastino = *lastinop; - agno =XFS_INO_TO_AGNO (mp, lastino); - agino =XFS_INO_TO_AGINO (mp, lastino); + agno =XFS_INO_TO_AGNO (mp, *lastinop); + agino =XFS_INO_TO_AGINO (mp, *lastinop);if (agno >= mp->m_sb.sb_agcount || - lastino !=XFS_AGINO_TO_INO (mp, agno, agino)) { + *lastinop !=XFS_AGINO_TO_INO (mp, agno, agino)) { *done =1 ; *ubcountp =0 ;return 0 ;
@@ -420,7 +424,6 @@ xfs_bulkstat( irbp->ir_freecount = r.ir_freecount; irbp->ir_free = r.ir_free; irbp++; - agino = r.ir_startino +XFS_INODES_PER_CHUNK ; }/* Increment to the next record */ error =xfs_btree_increment (cur,0 , &stat);
@@ -458,10 +461,6 @@ xfs_bulkstat( irbp++; icount +=XFS_INODES_PER_CHUNK - r.ir_freecount; } -/* -* Set agino to after this chunk and bump the cursor. -*/ - agino = r.ir_startino +XFS_INODES_PER_CHUNK ; error =xfs_btree_increment (cur,0 , &stat);if (error || stat ==0 ) { end_of_ag = true;
@@ -481,7 +480,9 @@ del_cursor:if (error)break ;/* -* Now format all the good inodes into the user's buffer. +* Now format all the good inodes into the user's buffer. The +* call to xfs_bulkstat_ag_ichunk() sets up the agino pointer +* for the next loop iteration. */ irbufend = irbp; for (irbp = irbuf;
@@ -489,7 +490,7 @@ del_cursor: irbp++) { error =xfs_bulkstat_ag_ichunk (mp, agno, irbp, formatter, statstruct_size, &ac, - &lastino); + &agino);if (error)break ;
@@ -506,8 +507,7 @@ del_cursor:if (end_of_ag) { agno++; agino =0 ; - }else - agino =XFS_INO_TO_AGINO (mp, lastino); + } }/* * Done, we're either out of filesystem or space to put the data.
@@ -525,16 +525,13 @@ del_cursor:if (ac.ac_ubelem) error =0 ; -if (agno >= mp->m_sb.sb_agcount) { -/* -* If we ran out of filesystem, mark lastino as off -* the end of the filesystem, so the next call -* will return immediately. -*/ - *lastinop = (xfs_ino_t )XFS_AGINO_TO_INO (mp, agno,0 ); +/* +* If we ran out of filesystem, lastino will point off the end of +* the filesystem so the next call will return immediately. +*/ + *lastinop =XFS_AGINO_TO_INO (mp, agno, agino); +if (agno >= mp->m_sb.sb_agcount) *done =1 ; - }else - *lastinop = (xfs_ino_t )lastino;return error; }
Greg Kroah-Hartman
maintainerPATCH 319/319 HID: add keyboard input assist hid usages
In reply to Greg Kroah-Hartman3.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olivier Gay <[email protected]>
commit f974008f07a62171a9dede08250c9a35c2b2b986 upstream.
Add keyboard input assist controls usages from approved hid usage table request HUTTR42:
http://www.usb.org/developers/hidpage/HUTRR42c.pdf
--- drivers/hid/hid-debug.c | 6 ++++++ drivers/hid/hid-input.c | 7 +++++++ include/uapi/linux/input.h | 7 +++++++ 3 files changed, 20 insertions(+)
drivers/hid/hid-debug.c +6 -0
@@ -946,6 +946,12 @@ static const char *keys[KEY_MAX + 1] = { [KEY_BRIGHTNESS_MIN] = "BrightnessMin", [KEY_BRIGHTNESS_MAX] = "BrightnessMax", [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto", + [KEY_KBDINPUTASSIST_PREV] = "KbdInputAssistPrev", + [KEY_KBDINPUTASSIST_NEXT] = "KbdInputAssistNext", + [KEY_KBDINPUTASSIST_PREVGROUP] = "KbdInputAssistPrevGroup", + [KEY_KBDINPUTASSIST_NEXTGROUP] = "KbdInputAssistNextGroup", + [KEY_KBDINPUTASSIST_ACCEPT] = "KbdInputAssistAccept", + [KEY_KBDINPUTASSIST_CANCEL] = "KbdInputAssistCancel", };static const char *relatives[REL_MAX +1 ] = {
drivers/hid/hid-input.c +7 -0
@@ -859,6 +859,13 @@ static void hidinput_configure_usage(strcase 0x28b :map_key_clear (KEY_FORWARDMAIL );break ;case 0x28c :map_key_clear (KEY_SEND );break ; +case 0x2c7 :map_key_clear (KEY_KBDINPUTASSIST_PREV );break ; +case 0x2c8 :map_key_clear (KEY_KBDINPUTASSIST_NEXT );break ; +case 0x2c9 :map_key_clear (KEY_KBDINPUTASSIST_PREVGROUP );break ; +case 0x2ca :map_key_clear (KEY_KBDINPUTASSIST_NEXTGROUP );break ; +case 0x2cb :map_key_clear (KEY_KBDINPUTASSIST_ACCEPT );break ; +case 0x2cc :map_key_clear (KEY_KBDINPUTASSIST_CANCEL );break ; +default : goto ignore; }break ;
include/uapi/linux/input.h +7 -0
@@ -739,6 +739,13 @@ struct input_keymap_entry {#define KEY_BRIGHTNESS_MIN 0x250/* Set Brightness to Minimum */ #define KEY_BRIGHTNESS_MAX 0x251/* Set Brightness to Maximum */ +#define KEY_KBDINPUTASSIST_PREV 0x260 +#define KEY_KBDINPUTASSIST_NEXT 0x261 +#define KEY_KBDINPUTASSIST_PREVGROUP 0x262 +#define KEY_KBDINPUTASSIST_NEXTGROUP 0x263 +#define KEY_KBDINPUTASSIST_ACCEPT 0x264 +#define KEY_KBDINPUTASSIST_CANCEL 0x265 +#define BTN_TRIGGER_HAPPY 0x2c0#define BTN_TRIGGER_HAPPY1 0x2c0#define BTN_TRIGGER_HAPPY2 0x2c1
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.17.3 release. There are 319 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Nov 14 01:07:52 UTC 2014. Anything received after that time might be too late.
Build results:
total: 133 pass: 132 fail: 1 Failed builds: avr32:atngw100mkii_evklcd101_defconfig
Qemu tests:
total: 30 pass: 30 fail: 0
The failing build is due to a link error:
lib/lib.a(vsprintf.o): In function `vsnprintf':
vsprintf.c:(.text+0x16dc): relocation truncated to fit:
R_AVR32_16N_PCREL against symbol `_ctype' defined in .text section in lib/lib.a(ctype.o)
which has been observed on and off for the last few releases.
Details are available at http://server.roeck-us.net:8010/builder.
Guenter
Greg Kroah-Hartman
maintainerQuoted 20 lines · Guenter Roeck
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.17.3 release. There are 319 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Nov 14 01:07:52 UTC 2014. Anything received after that time might be too late.
Build results:
total: 133 pass: 132 fail: 1 Failed builds: avr32:atngw100mkii_evklcd101_defconfigQemu tests:
total: 30 pass: 30 fail: 0The failing build is due to a link error:
Quoted 7 lines
lib/lib.a(vsprintf.o): In function `vsnprintf':
vsprintf.c:(.text+0x16dc): relocation truncated to fit:
R_AVR32_16N_PCRELagainst symbol `_ctype' defined in .text section in lib/lib.a(ctype.o)which has been observed on and off for the last few releases.
Details are available at http://server.roeck-us.net:8010/builder.
Thanks for testing, I'll not worry about avr32 as that's an odd one...
greg k-h
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 3.17.3 release. There are 319 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri Nov 14 01:07:52 UTC 2014. Anything received after that time might be too late.
Quoted 8 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.17.3-rc1.gzand the diffstat can be found below.
thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
-- Shuah
Signature · 4 lines
Shuah Khan Sr. Linux Kernel Developer Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978