clk: at91: usb: continue if clk_hw_round_rate() return zero
Subsystems (9)
Sasha Levin
maintainerPATCH 1/14 clk: at91: usb: continue if clk_hw_round_rate() return zero
From: Claudiu Beznea <[email protected]>
[ Upstream commit b0ecf1c6c6e82da4847900fad0272abfd014666d ]
clk_hw_round_rate() may call round rate function of its parents. In case of SAM9X60 two of USB parrents are PLLA and UPLL. These clocks are controlled by clk-sam9x60-pll.c driver. The round rate function for this driver is sam9x60_pll_round_rate() which call in turn sam9x60_pll_get_best_div_mul(). In case the requested rate is not in the proper range (rate < characteristics->output[0].min &&
rate > characteristics->output[0].max) the sam9x60_pll_round_rate() will return a negative number to its caller (called by clk_core_round_rate_nolock()). clk_hw_round_rate() will return zero in case a negative number is returned by clk_core_round_rate_nolock(). With this, the USB clock will continue its rate computation even caller of clk_hw_round_rate() returned an error. With this, the USB clock on SAM9X60 may not chose the best parent. I detected this after a suspend/resume cycle on SAM9X60.
--- drivers/clk/at91/clk-usb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/at91/clk-usb.c +3 -0
@@ -79,6 +79,9 @@ static int at91sam9x5_clk_usb_determine_rate(struct clk_hw *hw, tmp_parent_rate = req->rate * div; tmp_parent_rate =clk_hw_round_rate (parent, tmp_parent_rate); +if (!tmp_parent_rate) +continue ; + tmp_rate =DIV_ROUND_CLOSEST (tmp_parent_rate, div);if (tmp_rate < req->rate) tmp_diff = req->rate - tmp_rate;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/14 clk: tegra: Fix Tegra PMC clock out parents
From: Sowjanya Komatineni <[email protected]>
[ Upstream commit 6fe38aa8cac3a5db38154331742835a4d9740788 ]
Tegra PMC clocks clk_out_1, clk_out_2, and clk_out_3 supported parents are osc, osc_div2, osc_div4 and extern clock.
Clock driver is using incorrect parents clk_m, clk_m_div2, clk_m_div4 for PMC clocks.
This patch fixes this.
--- drivers/clk/tegra/clk-tegra-pmc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/clk/tegra/clk-tegra-pmc.c +6 -6
@@ -60,16 +60,16 @@ struct pmc_clk_init_data {static DEFINE_SPINLOCK (clk_out_lock); -static const char *clk_out1_parents[] = {"clk_m" ,"clk_m_div2" , -"clk_m_div4" ,"extern1" , +static const char *clk_out1_parents[] = {"osc" ,"osc_div2" , +"osc_div4" ,"extern1" , }; -static const char *clk_out2_parents[] = {"clk_m" ,"clk_m_div2" , -"clk_m_div4" ,"extern2" , +static const char *clk_out2_parents[] = {"osc" ,"osc_div2" , +"osc_div4" ,"extern2" , }; -static const char *clk_out3_parents[] = {"clk_m" ,"clk_m_div2" , -"clk_m_div4" ,"extern3" , +static const char *clk_out3_parents[] = {"osc" ,"osc_div2" , +"osc_div4" ,"extern3" , };static struct pmc_clk_init_data pmc_clks[] = {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/14 NFS: direct.c: Fix memory leak of dreq when nfs_get_lock_context fails
In reply to Sasha LevinFrom: Misono Tomohiro <[email protected]>
[ Upstream commit 8605cf0e852af3b2c771c18417499dc4ceed03d5 ]
When dreq is allocated by nfs_direct_req_alloc(), dreq->kref is initialized to 2. Therefore we need to call nfs_direct_req_release() twice to release the allocated dreq. Usually it is called in nfs_file_direct_{read, write}() and nfs_direct_complete().
However, current code only calls nfs_direct_req_relese() once if nfs_get_lock_context() fails in nfs_file_direct_{read, write}(). So, that case would result in memory leak.
Fix this by adding the missing call.
--- fs/nfs/direct.c | 2 ++ 1 file changed, 2 insertions(+)
fs/nfs/direct.c +2 -0
@@ -605,6 +605,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, struct iov_iter *iter, l_ctx =nfs_get_lock_context (dreq->ctx);if (IS_ERR (l_ctx)) { result =PTR_ERR (l_ctx); +nfs_direct_req_release (dreq); goto out_release; } dreq->l_ctx = l_ctx;
@@ -1015,6 +1016,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter) l_ctx =nfs_get_lock_context (dreq->ctx);if (IS_ERR (l_ctx)) { result =PTR_ERR (l_ctx); +nfs_direct_req_release (dreq); goto out_release; } dreq->l_ctx = l_ctx;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/14 ext4: do not commit super on read-only bdev
In reply to Sasha LevinFrom: Eric Sandeen <[email protected]>
[ Upstream commit c96e2b8564adfb8ac14469ebc51ddc1bfecb3ae2 ]
Under some circumstances we may encounter a filesystem error on a read-only block device, and if we try to save the error info to the superblock and commit it, we'll wind up with a noisy error and backtrace, i.e.:
[ 3337.146838] EXT4-fs error (device pmem1p2): ext4_get_journal_inode:4634: comm mount: inode #0: comm mount: iget: illegal inode # ------------[ cut here ]------------ generic_make_request: Trying to write to read-only block-device pmem1p2 (partno 2) WARNING: CPU: 107 PID: 115347 at block/blk-core.c:788 generic_make_request_checks+0x6b4/0x7d0
...
To avoid this, commit the error info in the superblock only if the block device is writable.
--- fs/ext4/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/super.c +2 -1
@@ -313,7 +313,8 @@ static void save_error_info(struct super_block *sb, const char *func, unsigned int line) {__save_error_info (sb, func, line); -ext4_commit_super (sb,1 ); +if (!bdev_read_only (sb->s_bdev)) +ext4_commit_super (sb,1 ); }/*
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/14 ext4: fix incorrect group count in ext4_fill_super error message
In reply to Sasha LevinFrom: Josh Triplett <[email protected]>
[ Upstream commit df41460a21b06a76437af040d90ccee03888e8e5 ]
ext4_fill_super doublechecks the number of groups before mounting; if that check fails, the resulting error message prints the group count from the ext4_sb_info sbi, which hasn't been set yet. Print the freshly computed group count instead (which at that point has just been computed in "blocks_count").
--- fs/ext4/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/super.c +2 -2
@@ -3792,9 +3792,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) EXT4_BLOCKS_PER_GROUP(sb) - 1);do_div (blocks_count,EXT4_BLOCKS_PER_GROUP (sb));if (blocks_count > ((uint64_t )1 <<32 ) -EXT4_DESC_PER_BLOCK (sb)) { -ext4_msg (sb,KERN_WARNING ,"groups count too large: %u " +ext4_msg (sb,KERN_WARNING ,"groups count too large: %llu " "(block count %llu, first data block %u, " -"blocks per group %lu)" , sbi->s_groups_count, +"blocks per group %lu)" , blocks_count,ext4_blocks_count (es),le32_to_cpu (es->s_first_data_block),EXT4_BLOCKS_PER_GROUP (sb));
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/14 ext4: fix incorrect inodes per group in error message
In reply to Sasha LevinFrom: Josh Triplett <[email protected]>
[ Upstream commit b9c538da4e52a7b79dfcf4cfa487c46125066dfb ]
If ext4_fill_super detects an invalid number of inodes per group, the resulting error message printed the number of blocks per group, rather than the number of inodes per group. Fix it to print the correct value.
--- fs/ext4/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/super.c +1 -1
@@ -3661,7 +3661,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)if (sbi->s_inodes_per_group < sbi->s_inodes_per_block || sbi->s_inodes_per_group > blocksize *8 ) {ext4_msg (sb,KERN_ERR ,"invalid inodes per group: %lu\n" , - sbi->s_blocks_per_group); + sbi->s_inodes_per_group); goto failed_mount; } sbi->s_itb_per_group = sbi->s_inodes_per_group /
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 7/14 slcan: Don't transmit uninitialized stack data in padding
In reply to Sasha LevinFrom: Richard Palethorpe <[email protected]>
[ Upstream commit b9258a2cece4ec1f020715fe3554bc2e360f6264 ]
struct can_frame contains some padding which is not explicitly zeroed in slc_bump. This uninitialized data will then be transmitted if the stack initialization hardening feature is not enabled (CONFIG_INIT_STACK_ALL).
This commit just zeroes the whole struct including the padding.
--- drivers/net/can/slcan.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/can/slcan.c +1 -3
@@ -147,7 +147,7 @@ static void slc_bump(struct slcan *sl)u32 tmpid;char *cmd = sl->rbuff; - cf.can_id =0 ; +memset (&cf,0 ,sizeof (cf));switch (*cmd) {case 'r' :
@@ -186,8 +186,6 @@ static void slc_bump(struct slcan *sl)else return ; - *(u64 *) (&cf.data) =0 ;/* clear payload */ -/* RTR frames may have a dlc > 0 but they never have any data bytes */ if (!(cf.can_id &CAN_RTR_FLAG )) {for (i =0 ; i < cf.can_dlc; i++) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 8/14 net: stmmac: dwmac1000: fix out-of-bounds mac address reg setting
In reply to Sasha LevinFrom: Jisheng Zhang <[email protected]>
[ Upstream commit 3e1221acf6a8f8595b5ce354bab4327a69d54d18 ]
Commit 9463c4455900 ("net: stmmac: dwmac1000: Clear unused address entries") cleared the unused mac address entries, but introduced an out-of bounds mac address register programming bug -- After setting the secondary unicast mac addresses, the "reg" value has reached netdev_uc_count() + 1, thus we should only clear address entries if (addr < perfect_addr_number)
--- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +1 -1
@@ -188,7 +188,7 @@ static void dwmac1000_set_filter(struct mac_device_info *hw, reg++; } -while (reg <= perfect_addr_number) { +while (reg < perfect_addr_number) {writel (0 , ioaddr +GMAC_ADDR_HIGH (reg));writel (0 , ioaddr +GMAC_ADDR_LOW (reg)); reg++;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/14 percpu_counter: fix a data race at vm_committed_as
In reply to Sasha LevinFrom: Qian Cai <[email protected]>
[ Upstream commit 7e2345200262e4a6056580f0231cccdaffc825f3 ]
"vm_committed_as.count" could be accessed concurrently as reported by KCSAN,
BUG: KCSAN: data-race in __vm_enough_memory / percpu_counter_add_batch
write to 0xffffffff9451c538 of 8 bytes by task 65879 on cpu 35:
percpu_counter_add_batch+0x83/0xd0 percpu_counter_add_batch at lib/percpu_counter.c:91 __vm_enough_memory+0xb9/0x260 dup_mm+0x3a4/0x8f0 copy_process+0x2458/0x3240 _do_fork+0xaa/0x9f0 __do_sys_clone+0x125/0x160 __x64_sys_clone+0x70/0x90 do_syscall_64+0x91/0xb05 entry_SYSCALL_64_after_hwframe+0x49/0xbe
read to 0xffffffff9451c538 of 8 bytes by task 66773 on cpu 19:
__vm_enough_memory+0x199/0x260 percpu_counter_read_positive at include/linux/percpu_counter.h:81 (inlined by) __vm_enough_memory at mm/util.c:839 mmap_region+0x1b2/0xa10 do_mmap+0x45c/0x700 vm_mmap_pgoff+0xc0/0x130 ksys_mmap_pgoff+0x6e/0x300 __x64_sys_mmap+0x33/0x40 do_syscall_64+0x91/0xb05 entry_SYSCALL_64_after_hwframe+0x49/0xbe
The read is outside percpu_counter::lock critical section which results in a data race. Fix it by adding a READ_ONCE() in percpu_counter_read_positive() which could also service as the existing compiler memory barrier.
--- include/linux/percpu_counter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/percpu_counter.h +2 -2
@@ -76,9 +76,9 @@ static inline s64 percpu_counter_read(struct percpu_counter *fbc)*/ static inline s64 percpu_counter_read_positive (struct percpu_counter *fbc) { -s64 ret = fbc->count; +/* Prevent reloads of fbc->count */ +s64 ret =READ_ONCE (fbc->count); -barrier ();/* Prevent reloads of fbc->count */ if (ret >=0 )return ret;return 0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 10/14 compiler.h: fix error in BUILD_BUG_ON() reporting
In reply to Sasha LevinFrom: Vegard Nossum <[email protected]>
[ Upstream commit af9c5d2e3b355854ff0e4acfbfbfadcd5198a349 ]
compiletime_assert() uses __LINE__ to create a unique function name. This means that if you have more than one BUILD_BUG_ON() in the same source line (which can happen if they appear e.g. in a macro), then the error message from the compiler might output the wrong condition.
For this source file:
#include <linux/build_bug.h>
#define macro() \
BUILD_BUG_ON(1); \
BUILD_BUG_ON(0);
void foo()
{
macro();
}gcc would output:
./include/linux/compiler.h:350:38: error: call to `__compiletime_assert_9' declared with attribute error: BUILD_BUG_ON failed: 0
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
However, it was not the BUILD_BUG_ON(0) that failed, so it should say 1 instead of 0. With this patch, we use __COUNTER__ instead of __LINE__, so each BUILD_BUG_ON() gets a different function name and the correct condition is printed:
./include/linux/compiler.h:350:38: error: call to `__compiletime_assert_0' declared with attribute error: BUILD_BUG_ON failed: 1
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
--- include/linux/compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/compiler.h +1 -1
@@ -502,7 +502,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s* compiler has support to do so. */ #define compiletime_assert (condition, msg) \ - _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) + _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)#define compiletime_assert_atomic_type (t) \ compiletime_assert(__native_word(t), \
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 11/14 NFS: Fix memory leaks in nfs_pageio_stop_mirroring()
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
[ Upstream commit 862f35c94730c9270833f3ad05bd758a29f204ed ]
If we just set the mirror count to 1 without first clearing out the mirrors, we can leak queued up requests.
--- fs/nfs/pagelist.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
fs/nfs/pagelist.c +8 -9
@@ -886,15 +886,6 @@ static int nfs_pageio_setup_mirroring(struct nfs_pageio_descriptor *pgio,return 0 ; } -/* -* nfs_pageio_stop_mirroring - stop using mirroring (set mirror count to 1) -*/ -void nfs_pageio_stop_mirroring (struct nfs_pageio_descriptor *pgio) -{ - pgio->pg_mirror_count =1 ; - pgio->pg_mirror_idx =0 ; -} -static void nfs_pageio_cleanup_mirroring (struct nfs_pageio_descriptor *pgio) { pgio->pg_mirror_count =1 ;
@@ -1287,6 +1278,14 @@ void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *desc, pgoff_t index) } } +/* +* nfs_pageio_stop_mirroring - stop using mirroring (set mirror count to 1) +*/ +void nfs_pageio_stop_mirroring (struct nfs_pageio_descriptor *pgio) +{ +nfs_pageio_complete (pgio); +} +int __init nfs_init_nfspagecache (void ) { nfs_page_cachep = kmem_cache_create("nfs_page",
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 12/14 mfd: dln2: Fix sanity checking for endpoints
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit fb945c95a482200876993977008b67ea658bd938 ]
While the commit 2b8bd606b1e6 ("mfd: dln2: More sanity checking for endpoints") tries to harden the sanity checks it made at the same time a regression, i.e. mixed in and out endpoints. Obviously it should have been not tested on real hardware at that time, but unluckily it didn't happen.
So, fix above mentioned typo and make device being enumerated again.
While here, introduce an enumerator for magic values to prevent similar issue to happen in the future.
--- drivers/mfd/dln2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mfd/dln2.c +7 -2
@@ -93,6 +93,11 @@ struct dln2_mod_rx_slots {spinlock_t lock; }; +enum dln2_endpoint { +DLN2_EP_OUT =0 , +DLN2_EP_IN =1 , +}; +struct dln2_dev {struct usb_device *usb_dev;struct usb_interface *interface;
@@ -740,10 +745,10 @@ static int dln2_probe(struct usb_interface *interface, hostif->desc.bNumEndpoints < 2)return -ENODEV ; - epin = &hostif->endpoint[0 ].desc; - epout = &hostif->endpoint[1 ].desc; + epout = &hostif->endpoint[DLN2_EP_OUT ].desc;if (!usb_endpoint_is_bulk_out (epout))return -ENODEV ; + epin = &hostif->endpoint[DLN2_EP_IN ].desc;if (!usb_endpoint_is_bulk_in (epin))return -ENODEV ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 13/14 ext2: fix empty body warnings when -Wextra is used
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
[ Upstream commit 44a52022e7f15cbaab957df1c14f7a4f527ef7cf ]
When EXT2_ATTR_DEBUG is not defined, modify the 2 debug macros to use the no_printk() macro instead of <nothing>. This fixes gcc warnings when -Wextra is used:
../fs/ext2/xattr.c:252:42: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] ../fs/ext2/xattr.c:258:42: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] ../fs/ext2/xattr.c:330:42: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body] ../fs/ext2/xattr.c:872:45: warning: suggest braces around empty body in an ‘else’ statement [-Wempty-body]
I have verified that the only object code change (with gcc 7.5.0) is the reversal of some instructions from 'cmp a,b' to 'cmp b,a'.
--- fs/ext2/xattr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ext2/xattr.c +3 -2
@@ -55,6 +55,7 @@#include <linux/buffer_head.h> #include <linux/init.h> +#include <linux/printk.h> #include <linux/slab.h> #include <linux/mbcache.h> #include <linux/quotaops.h>
@@ -85,8 +86,8 @@printk ("\n" ); \ } while (0) #else -# define ea_idebug(f...) -# define ea_bdebug(f...) +# define ea_idebug(inode, f...) no_printk(f) +# define ea_bdebug(bh, f...) no_printk(f)#endif static int ext2_xattr_set2(struct inode *, struct buffer_head *,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 14/14 iommu/amd: Fix the configuration of GCR3 table root pointer
In reply to Sasha LevinFrom: Adrian Huang <[email protected]>
[ Upstream commit c20f36534666e37858a14e591114d93cc1be0d34 ]
The SPA of the GCR3 table root pointer[51:31] masks 20 bits. However, this requires 21 bits (Please see the AMD IOMMU specification). This leads to the potential failure when the bit 51 of SPA of the GCR3 table root pointer is 1'.
--- drivers/iommu/amd_iommu_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd_iommu_types.h +1 -1
@@ -303,7 +303,7 @@#define DTE_GCR3_VAL_A (x) (((x) >> 12) & 0x00007ULL)#define DTE_GCR3_VAL_B (x) (((x) >> 15) & 0x0ffffULL) -#define DTE_GCR3_VAL_C (x) (((x) >> 31) & 0xfffffULL) +#define DTE_GCR3_VAL_C (x) (((x) >> 31) & 0x1fffffULL)#define DTE_GCR3_INDEX_A 0#define DTE_GCR3_INDEX_B 1
Signature · 6 lines
2.20.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu