gfs2: Fix lru_count going negative
Subsystems (26)
Sasha Levin
maintainerPATCH 1/167 gfs2: Fix lru_count going negative
From: Ross Lagerwall <[email protected]>
[ Upstream commit 7881ef3f33bb80f459ea6020d1e021fc524a6348 ]
Under certain conditions, lru_count may drop below zero resulting in a large amount of log spam like this:
vmscan: shrink_slab: gfs2_dump_glock+0x3b0/0x630 [gfs2] \
negative objects to delete nr=-1
This happens as follows:
1) A glock is moved from lru_list to the dispose list and lru_count is decremented.
2) The dispose function calls cond_resched() and drops the lru lock.
3) Another thread takes the lru lock and tries to add the same glock to lru_list, checking if the glock is on an lru list.
4) It is on a list (actually the dispose list) and so it avoids incrementing lru_count.
5) The glock is moved to lru_list.
5) The original thread doesn't dispose it because it has been re-added to the lru list but the lru_count has still decreased by one.
Fix by checking if the LRU flag is set on the glock rather than checking if the glock is on some list and rearrange the code so that the LRU flag is added/removed precisely when the glock is added/removed from lru_list.
--- fs/gfs2/glock.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
fs/gfs2/glock.c +13 -9
@@ -183,15 +183,19 @@ static int demote_ok(const struct gfs2_glock *gl)void gfs2_glock_add_to_lru (struct gfs2_glock *gl) { +if (!(gl->gl_ops->go_flags &GLOF_LRU )) +return ; +spin_lock (&lru_lock); -if (!list_empty (&gl->gl_lru)) -list_del_init (&gl->gl_lru); -else +list_del (&gl->gl_lru); +list_add_tail (&gl->gl_lru, &lru_list); + +if (!test_bit (GLF_LRU , &gl->gl_flags)) { +set_bit (GLF_LRU , &gl->gl_flags);atomic_inc (&lru_count); + } -list_add_tail (&gl->gl_lru, &lru_list); -set_bit (GLF_LRU , &gl->gl_flags);spin_unlock (&lru_lock); }
@@ -201,7 +205,7 @@ static void gfs2_glock_remove_from_lru(struct gfs2_glock *gl)return ;spin_lock (&lru_lock); -if (!list_empty (&gl->gl_lru)) { +if (test_bit (GLF_LRU , &gl->gl_flags)) {list_del_init (&gl->gl_lru);atomic_dec (&lru_count);clear_bit (GLF_LRU , &gl->gl_flags);
@@ -1158,8 +1162,7 @@ void gfs2_glock_dq(struct gfs2_holder *gh) !test_bit(GLF_DEMOTE, &gl->gl_flags)) fast_path =1 ; } -if (!test_bit (GLF_LFLUSH , &gl->gl_flags) &&demote_ok (gl) && - (glops->go_flags &GLOF_LRU )) +if (!test_bit (GLF_LFLUSH , &gl->gl_flags) &&demote_ok (gl))gfs2_glock_add_to_lru (gl);trace_gfs2_glock_queue (gh,0 );
@@ -1454,6 +1457,7 @@ __acquires(&lru_lock)if (!spin_trylock (&gl->gl_lockref.lock)) { add_back_to_lru:list_add (&gl->gl_lru, &lru_list); +set_bit (GLF_LRU , &gl->gl_flags);atomic_inc (&lru_count);continue ; }
@@ -1461,7 +1465,6 @@ __acquires(&lru_lock)spin_unlock (&gl->gl_lockref.lock); goto add_back_to_lru; } -clear_bit (GLF_LRU , &gl->gl_flags); gl->gl_lockref.count++;if (demote_ok (gl))handle_callback (gl,LM_ST_UNLOCKED ,0 , false);
@@ -1496,6 +1499,7 @@ static long gfs2_scan_glock_lru(int nr)if (!test_bit (GLF_LOCK , &gl->gl_flags)) {list_move (&gl->gl_lru, &dispose);atomic_dec (&lru_count); +clear_bit (GLF_LRU , &gl->gl_flags); freed++;continue ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/167 cxgb4: Fix error path in cxgb4_init_module
From: YueHaibing <[email protected]>
[ Upstream commit a3147770bea76c8dbad73eca3a24c2118da5e719 ]
BUG: unable to handle kernel paging request at ffffffffa016a270 PGD 3270067 P4D 3270067 PUD 3271063 PMD 230bbd067 PTE 0 Oops: 0000 [#1 CPU: 0 PID: 6134 Comm: modprobe Not tainted 5.1.0+ #33 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014 RIP: 0010:atomic_notifier_chain_register+0x24/0x60 Code: 1f 80 00 00 00 00 55 48 89 e5 41 54 49 89 f4 53 48 89 fb e8 ae b4 38 01 48 8b 53 38 48 8d 4b 38 48 85 d2 74 20 45 8b 44 24 10 <44> 3b 42 10 7e 08 eb 13 44 39 42 10 7c 0d 48 8d 4a 08 48 8b 52 08 RSP: 0018:ffffc90000e2bc60 EFLAGS: 00010086 RAX: 0000000000000292 RBX: ffffffff83467240 RCX: ffffffff83467278 RDX: ffffffffa016a260 RSI: ffffffff83752140 RDI: ffffffff83467240 RBP: ffffc90000e2bc70 R08: 0000000000000000 R09: 0000000000000001 R10: 0000000000000000 R11: 00000000014fa61f R12: ffffffffa01c8260 R13: ffff888231091e00 R14: 0000000000000000 R15: ffffc90000e2be78 FS: 00007fbd8d7cd540(0000) GS:ffff888237a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffa016a270 CR3: 000000022c7e3000 CR4: 00000000000006f0 Call Trace: register_inet6addr_notifier+0x13/0x20 cxgb4_init_module+0x6c/0x1000 [cxgb4 ? 0xffffffffa01d7000 do_one_initcall+0x6c/0x3cc ? do_init_module+0x22/0x1f1 ? rcu_read_lock_sched_held+0x97/0xb0 ? kmem_cache_alloc_trace+0x325/0x3b0 do_init_module+0x5b/0x1f1 load_module+0x1db1/0x2690 ? m_show+0x1d0/0x1d0 __do_sys_finit_module+0xc5/0xd0 __x64_sys_finit_module+0x15/0x20 do_syscall_64+0x6b/0x1d0 entry_SYSCALL_64_after_hwframe+0x49/0xbe
If pci_register_driver fails, register inet6addr_notifier is pointless. This patch fix the error path in cxgb4_init_module.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +12 -3
@@ -5399,15 +5399,24 @@ static int __init cxgb4_init_module(void) ret =pci_register_driver (&cxgb4_driver);if (ret <0 ) -debugfs_remove (cxgb4_debugfs_root); + goto err_pci;#if IS_ENABLED (CONFIG_IPV6 )if (!inet6addr_registered) { -register_inet6addr_notifier (&cxgb4_inet6addr_notifier); - inet6addr_registered = true; + ret =register_inet6addr_notifier (&cxgb4_inet6addr_notifier); +if (ret) +pci_unregister_driver (&cxgb4_driver); +else + inet6addr_registered = true; }#endif +if (ret ==0 ) +return ret; + +err_pci: +debugfs_remove (cxgb4_debugfs_root); +return ret; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/167 NFS: make nfs_match_client killable
In reply to Sasha LevinFrom: Roberto Bergantinos Corpas <[email protected]>
[ Upstream commit 950a578c6128c2886e295b9c7ecb0b6b22fcc92b ]
Actually we don't do anything with return value from nfs_wait_client_init_complete in nfs_match_client, as a consequence if we get a fatal signal and client is not fully initialised, we'll loop to "again" label
This has been proven to cause soft lockups on some scenarios (no-carrier but configured network interfaces)
--- fs/nfs/client.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/nfs/client.c +6 -1
@@ -290,6 +290,7 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *datstruct nfs_client *clp;const struct sockaddr *sap = data->addr;struct nfs_net *nn =net_generic (data->net, nfs_net_id); +int error; again:list_for_each_entry (clp, &nn->nfs_client_list, cl_share_link) {
@@ -302,8 +303,10 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *datif (clp->cl_cons_state >NFS_CS_READY ) {atomic_inc (&clp->cl_count);spin_unlock (&nn->nfs_client_lock); -nfs_wait_client_init_complete (clp); + error =nfs_wait_client_init_complete (clp);nfs_put_client (clp); +if (error <0 ) +return ERR_PTR (error);spin_lock (&nn->nfs_client_lock); goto again; }
@@ -413,6 +416,8 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init) clp =nfs_match_client (cl_init);if (clp) {spin_unlock (&nn->nfs_client_lock); +if (IS_ERR (clp)) +return clp;if (new) new->rpc_ops->free_client (new);return nfs_found_client (cl_init, clp);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/167 IB/hfi1: Fix WQ_MEM_RECLAIM warning
In reply to Sasha LevinFrom: Mike Marciniszyn <[email protected]>
[ Upstream commit 4c4b1996b5db688e2dcb8242b0a3bf7b1e845e42 ]
The work_item cancels that occur when a QP is destroyed can elicit the following trace:
workqueue: WQ_MEM_RECLAIM ipoib_wq:ipoib_cm_tx_reap [ib_ipoib] is flushing !WQ_MEM_RECLAIM hfi0_0:_hfi1_do_send [hfi1]
WARNING: CPU: 7 PID: 1403 at kernel/workqueue.c:2486 check_flush_dependency+0xb1/0x100 Call Trace: __flush_work.isra.29+0x8c/0x1a0 ? __switch_to_asm+0x40/0x70 __cancel_work_timer+0x103/0x190 ? schedule+0x32/0x80 iowait_cancel_work+0x15/0x30 [hfi1] rvt_reset_qp+0x1f8/0x3e0 [rdmavt] rvt_destroy_qp+0x65/0x1f0 [rdmavt] ? _cond_resched+0x15/0x30 ib_destroy_qp+0xe9/0x230 [ib_core] ipoib_cm_tx_reap+0x21c/0x560 [ib_ipoib] process_one_work+0x171/0x370 worker_thread+0x49/0x3f0 kthread+0xf8/0x130 ? max_active_store+0x80/0x80 ? kthread_bind+0x10/0x10 ret_from_fork+0x35/0x40
Since QP destruction frees memory, hfi1_wq should have the WQ_MEM_RECLAIM.
The hfi1_wq does not allocate memory with GFP_KERNEL or otherwise become entangled with memory reclaim, so this flag is appropriate.
--- drivers/infiniband/hw/hfi1/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/init.c +2 -1
@@ -769,7 +769,8 @@ static int create_workqueues(struct hfi1_devdata *dd) ppd->hfi1_wq =alloc_workqueue ("hfi%d_%d" , -WQ_SYSFS |WQ_HIGHPRI |WQ_CPU_INTENSIVE , +WQ_SYSFS |WQ_HIGHPRI |WQ_CPU_INTENSIVE | +WQ_MEM_RECLAIM ,HFI1_MAX_ACTIVE_WORKQUEUE_ENTRIES , dd->unit, pidx);if (!ppd->hfi1_wq)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/167 gfs2: Fix occasional glock use-after-free
In reply to Sasha LevinFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit 9287c6452d2b1f24ea8e84bd3cf6f3c6f267f712 ]
This patch has to do with the life cycle of glocks and buffers. When gfs2 metadata or journaled data is queued to be written, a gfs2_bufdata object is assigned to track the buffer, and that is queued to various lists, including the glock's gl_ail_list to indicate it's on the active items list. Once the page associated with the buffer has been written, it is removed from the ail list, but its life isn't over until a revoke has been successfully written.
So after the block is written, its bufdata object is moved from the glock's gl_ail_list to a file-system-wide list of pending revokes, sd_log_le_revoke. At that point the glock still needs to track how many revokes it contributed to that list (in gl_revokes) so that things like glock go_sync can ensure all the metadata has been not only written, but also revoked before the glock is granted to a different node. This is to guarantee journal replay doesn't replay the block once the glock has been granted to another node.
Ross Lagerwall recently discovered a race in which an inode could be evicted, and its glock freed after its ail list had been synced, but while it still had unwritten revokes on the sd_log_le_revoke list. The evict decremented the glock reference count to zero, which allowed the glock to be freed. After the revoke was written, function revoke_lo_after_commit tried to adjust the glock's gl_revokes counter and clear its GLF_LFLUSH flag, at which time it referenced the freed glock.
This patch fixes the problem by incrementing the glock reference count in gfs2_add_revoke when the glock's first bufdata object is moved from the glock to the global revokes list. Later, when the glock's last such bufdata object is freed, the reference count is decremented. This guarantees that whichever process finishes last (the revoke writing or the evict) will properly free the glock, and neither will reference the glock after it has been freed.
--- fs/gfs2/glock.c | 1 + fs/gfs2/log.c | 3 ++- fs/gfs2/lops.c | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-)
fs/gfs2/glock.c +1 -0
@@ -140,6 +140,7 @@ void gfs2_glock_free(struct gfs2_glock *gl) {struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; +BUG_ON (atomic_read (&gl->gl_revokes));rhashtable_remove_fast (&gl_hash_table, &gl->gl_node, ht_parms);smp_mb ();wake_up_glock (gl);
fs/gfs2/log.c +2 -1
@@ -588,7 +588,8 @@ void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) bd->bd_bh =NULL ; bd->bd_ops = &gfs2_revoke_lops; sdp->sd_log_num_revoke++; -atomic_inc (&gl->gl_revokes); +if (atomic_inc_return (&gl->gl_revokes) ==1 ) +gfs2_glock_hold (gl);set_bit (GLF_LFLUSH , &gl->gl_flags);list_add (&bd->bd_list, &sdp->sd_log_le_revoke); }
fs/gfs2/lops.c +4 -2
@@ -660,8 +660,10 @@ static void revoke_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) bd = list_entry(head->next, struct gfs2_bufdata, bd_list);list_del_init (&bd->bd_list); gl = bd->bd_gl; -atomic_dec (&gl->gl_revokes); -clear_bit (GLF_LFLUSH , &gl->gl_flags); +if (atomic_dec_return (&gl->gl_revokes) ==0 ) { +clear_bit (GLF_LFLUSH , &gl->gl_flags); +gfs2_glock_queue_put (gl); + }kmem_cache_free (gfs2_bufdata_cachep, bd); } }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/167 mmc: core: Verify SD bus width
In reply to Sasha LevinFrom: Raul E Rangel <[email protected]>
[ Upstream commit 9e4be8d03f50d1b25c38e2b59e73b194c130df7d ]
The SD Physical Layer Spec says the following: Since the SD Memory Card shall support at least the two bus modes 1-bit or 4-bit width, then any SD Card shall set at least bits 0 and 2 (SD_BUS_WIDTH="0101").
This change verifies the card has specified a bus width.
AMD SDHC Device 7806 can get into a bad state after a card disconnect where anything transferred via the DATA lines will always result in a zero filled buffer. Currently the driver will continue without error if the HC is in this condition. A block device will be created, but reading from it will result in a zero buffer. This makes it seem like the SD device has been erased, when in actuality the data is never getting copied from the DATA lines to the data buffer.
SCR is the first command in the SD initialization sequence that uses the DATA lines. By checking that the response was invalid, we can abort mounting the card.
--- drivers/mmc/core/sd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mmc/core/sd.c +8 -0
@@ -216,6 +216,14 @@ static int mmc_decode_scr(struct mmc_card *card)if (scr->sda_spec3) scr->cmds =UNSTUFF_BITS (resp,32 ,2 ); + +/* SD Spec says: any SD Card shall set at least bits 0 and 2 */ +if (!(scr->bus_widths &SD_SCR_BUS_WIDTH_1 ) || + !(scr->bus_widths &SD_SCR_BUS_WIDTH_4 )) { +pr_err ("%s: invalid bus width\n" ,mmc_hostname (card->host)); +return -EINVAL ; + } +return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 7/167 tools/bpf: fix perf build error with uClibc (seen on ARC)
In reply to Sasha LevinFrom: Vineet Gupta <[email protected]>
[ Upstream commit ca31ca8247e2d3807ff5fa1d1760616a2292001c ]
When build perf for ARC recently, there was a build failure due to lack of __NR_bpf.
| Auto-detecting system features:
|
| ... get_cpuid: [ OFF ]
| ... bpf: [ on ]
|
| # error __NR_bpf not defined. libbpf does not support your arch.
^~~~~
| bpf.c: In function 'sys_bpf':
| bpf.c:66:17: error: '__NR_bpf' undeclared (first use in this function)
| return syscall(__NR_bpf, cmd, attr, size);
| ^~~~~~~~
| sys_bpf--- tools/lib/bpf/bpf.c | 2 ++ 1 file changed, 2 insertions(+)
tools/lib/bpf/bpf.c +2 -0
@@ -41,6 +41,8 @@# define __NR_bpf 349# elif defined(__s390__)# define __NR_bpf 351 +# elif defined(__arc__) +# define __NR_bpf 280# else # error __NR_bpf not defined. libbpf does not support your arch.# endif
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 8/167 dmaengine: tegra210-dma: free dma controller in remove()
In reply to Sasha LevinFrom: Sameer Pujar <[email protected]>
[ Upstream commit f030e419501cb95e961e9ed35c493b5d46a04eca ]
Following kernel panic is seen during DMA driver unload->load sequence
==========================================================================
Unable to handle kernel paging request at virtual address ffffff8001198880 Internal error: Oops: 86000007 [#1] PREEMPT SMP CPU: 0 PID: 5907 Comm: HwBinder:4123_1 Tainted: G C 4.9.128-tegra-g065839f Hardware name: galen (DT) task: ffffffc3590d1a80 task.stack: ffffffc3d0678000 PC is at 0xffffff8001198880 LR is at of_dma_request_slave_channel+0xd8/0x1f8 pc : [<ffffff8001198880>] lr : [<ffffff8008746f30>] pstate: 60400045
sp : ffffffc3d067b710
x29: ffffffc3d067b710 x28: 000000000000002f
x27: ffffff800949e000 x26: ffffff800949e750
x25: ffffff800949e000 x24: ffffffbefe817d84
x23: ffffff8009f77cb0 x22: 0000000000000028
x21: ffffffc3ffda49c8 x20: 0000000000000029
x19: 0000000000000001 x18: ffffffffffffffff
x17: 0000000000000000 x16: ffffff80082b66a0
x15: ffffff8009e78250 x14: 000000000000000a
x13: 0000000000000038 x12: 0101010101010101
x11: 0000000000000030 x10: 0101010101010101
x9 : fffffffffffffffc x8 : 7f7f7f7f7f7f7f7f
x7 : 62ff726b6b64622c x6 : 0000000000008064
x5 : 6400000000000000 x4 : ffffffbefe817c44
x3 : ffffffc3ffda3e08 x2 : ffffff8001198880
x1 : ffffffc3d48323c0 x0 : ffffffc3d067b788
Process HwBinder:4123_1 (pid: 5907, stack limit = 0xffffffc3d0678028)
Call trace: [<ffffff8001198880>] 0xffffff8001198880 [<ffffff80087459f8>] dma_request_chan+0x50/0x1f0 [<ffffff8008745bc0>] dma_request_slave_channel+0x28/0x40 [<ffffff8001552c44>] tegra_alt_pcm_open+0x114/0x170 [<ffffff8008d65fa4>] soc_pcm_open+0x10c/0x878 [<ffffff8008d18618>] snd_pcm_open_substream+0xc0/0x170 [<ffffff8008d1878c>] snd_pcm_open+0xc4/0x240 [<ffffff8008d189e0>] snd_pcm_playback_open+0x58/0x80 [<ffffff8008cfc6d4>] snd_open+0xb4/0x178 [<ffffff8008250628>] chrdev_open+0xb8/0x1d0 [<ffffff8008246fdc>] do_dentry_open+0x214/0x318 [<ffffff80082485d0>] vfs_open+0x58/0x88 [<ffffff800825bce0>] do_last+0x450/0xde0 [<ffffff800825c718>] path_openat+0xa8/0x368 [<ffffff800825dd84>] do_filp_open+0x8c/0x110 [<ffffff8008248a74>] do_sys_open+0x164/0x220 [<ffffff80082b66dc>] compat_SyS_openat+0x3c/0x50 [<ffffff8008083040>] el0_svc_naked+0x34/0x38 ---[ end trace 67e6d544e65b5145 ]--- Kernel panic - not syncing: Fatal exception ==========================================================================
In device probe(), of_dma_controller_register() registers DMA controller. But when driver is removed, this is not freed. During driver reload this results in data abort and kernel panic. Add of_dma_controller_free() in driver remove path to fix the issue.
--- drivers/dma/tegra210-adma.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/tegra210-adma.c +1 -0
@@ -786,6 +786,7 @@ static int tegra_adma_remove(struct platform_device *pdev)struct tegra_adma *tdma =platform_get_drvdata (pdev);int i; +of_dma_controller_free (pdev->dev.of_node);dma_async_device_unregister (&tdma->dma_dev);for (i =0 ; i < tdma->nr_channels; ++i)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/167 net: ena: gcc 8: fix compilation warning
In reply to Sasha LevinFrom: Sameeh Jubran <[email protected]>
[ Upstream commit f913308879bc6ae437ce64d878c7b05643ddea44 ]
GCC 8 contains a number of new warnings as well as enhancements to existing checkers. The warning - Wstringop-truncation - warns for calls to bounded string manipulation functions such as strncat, strncpy, and stpncpy that may either truncate the copied string or leave the destination unchanged.
In our case the destination string length (32 bytes) is much shorter than the source string (64 bytes) which causes this warning to show up. In general the destination has to be at least a byte larger than the length of the source string with strncpy for this warning not to showup.
This can be easily fixed by using strlcpy instead which already does the truncation to the string. Documentation for this function can be found here:
https://elixir.bootlin.com/linux/latest/source/lib/string.c#L141
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +1 -1
@@ -2229,7 +2229,7 @@ static void ena_config_host_info(struct ena_com_dev *ena_dev) host_info->os_type =ENA_ADMIN_OS_LINUX ; host_info->kernel_ver =LINUX_VERSION_CODE ; -strncpy (host_info->kernel_ver_str,utsname ()->version, +strlcpy (host_info->kernel_ver_str,utsname ()->version,sizeof (host_info->kernel_ver_str) -1 ); host_info->os_dist =0 ; strncpy(host_info->os_dist_str, utsname()->release,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 10/167 orangefs: truncate before updating size
In reply to Sasha LevinFrom: Martin Brandenburg <[email protected]>
[ Upstream commit 33713cd09ccdc1e01b10d0782ae60200d4989553 ]
Otherwise we race with orangefs_writepage/orangefs_writepages which and does not expect i_size < page_offset.
Fixes xfstests generic/129.
--- fs/orangefs/inode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/orangefs/inode.c +5 -1
@@ -172,7 +172,11 @@ static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr) } orig_size =i_size_read (inode); -truncate_setsize (inode, iattr->ia_size); +/* This is truncate_setsize in a different order. */ +truncate_pagecache (inode, iattr->ia_size); +i_size_write (inode, iattr->ia_size); +if (iattr->ia_size > orig_size) +pagecache_isize_extended (inode, orig_size, iattr->ia_size); new_op =op_alloc (ORANGEFS_VFS_OP_TRUNCATE );if (!new_op)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 11/167 pinctrl: zte: fix leaked of_node references
In reply to Sasha LevinFrom: Wen Yang <[email protected]>
[ Upstream commit 02d15f0d80720545f1f4922a1550ea4aaad4e152 ]
The call to of_parse_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage.
Detected by coccinelle with the following warnings:
./drivers/pinctrl/zte/pinctrl-zx.c:415:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function. ./drivers/pinctrl/zte/pinctrl-zx.c:422:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function. ./drivers/pinctrl/zte/pinctrl-zx.c:436:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function. ./drivers/pinctrl/zte/pinctrl-zx.c:444:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function. ./drivers/pinctrl/zte/pinctrl-zx.c:448:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 407, but without a corresponding object release within this function.
--- drivers/pinctrl/zte/pinctrl-zx.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/zte/pinctrl-zx.c +1 -0
@@ -411,6 +411,7 @@ int zx_pinctrl_init(struct platform_device *pdev, } zpctl->aux_base =of_iomap (np,0 ); +of_node_put (np);if (!zpctl->aux_base)return -ENOMEM ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 12/167 ASoC: hdmi-codec: unlock the device on startup errors
In reply to Sasha LevinFrom: Jerome Brunet <[email protected]>
[ Upstream commit 30180e8436046344b12813dc954b2e01dfdcd22d ]
If the hdmi codec startup fails, it should clear the current_substream pointer to free the device. This is properly done for the audio_startup() callback but for snd_pcm_hw_constraint_eld().
Make sure the pointer cleared if an error is reported.
--- sound/soc/codecs/hdmi-codec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/codecs/hdmi-codec.c +5 -1
@@ -446,8 +446,12 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,if (!ret) { ret =snd_pcm_hw_constraint_eld (substream->runtime, hcp->eld); -if (ret) +if (ret) { +mutex_lock (&hcp->current_stream_lock); + hcp->current_stream =NULL ; +mutex_unlock (&hcp->current_stream_lock);return ret; + } }/* Select chmap supported */ hdmi_codec_eld_chmap (hcp);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 13/167 leds: avoid races with workqueue
In reply to Sasha LevinFrom: Pavel Machek <[email protected]>
[ Upstream commit 0db37915d912e8dc6588f25da76d3ed36718d92f ]
There are races between "main" thread and workqueue. They manifest themselves on Thinkpad X60:
This should result in LED blinking, but it turns it off instead:
root@amd:/data/pavel# cd /sys/class/leds/tpacpi\:\:power
root@amd:/sys/class/leds/tpacpi::power# echo timer > trigger
root@amd:/sys/class/leds/tpacpi::power# echo timer > triggerIt should be possible to transition from blinking to solid on by echo 0 > brightness; echo 1 > brightness... but that does not work, either, if done too quickly.
Synchronization of the workqueue fixes both.
--- drivers/leds/led-class.c | 1 + drivers/leds/led-core.c | 5 +++++ 2 files changed, 6 insertions(+)
drivers/leds/led-class.c +1 -0
@@ -57,6 +57,7 @@ static ssize_t brightness_store(struct device *dev,if (state ==LED_OFF )led_trigger_remove (led_cdev);led_set_brightness (led_cdev, state); +flush_work (&led_cdev->set_brightness_work); ret = size; unlock:
drivers/leds/led-core.c +5 -0
@@ -162,6 +162,11 @@ static void led_blink_setup(struct led_classdev *led_cdev,unsigned long *delay_on, unsigned long *delay_off) { +/* +* If "set brightness to 0" is pending in workqueue, we don't +* want that to be reordered after blink_set() +*/ + flush_work(&led_cdev->set_brightness_work);if (!test_bit (LED_BLINK_ONESHOT , &led_cdev->work_flags) && led_cdev->blink_set && !led_cdev->blink_set (led_cdev, delay_on, delay_off))
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 14/167 powerpc/perf: Return accordingly on invalid chip-id in
In reply to Sasha LevinFrom: Anju T Sudhakar <[email protected]>
[ Upstream commit a913e5e8b43be1d3897a141ce61c1ec071cad89c ]
Nest hardware counter memory resides in a per-chip reserve-memory. During nest_imc_event_init(), chip-id of the event-cpu is considered to calculate the base memory addresss for that cpu. Return, proper error condition if the chip_id calculated is invalid.
--- arch/powerpc/perf/imc-pmu.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/perf/imc-pmu.c +5 -0
@@ -481,6 +481,11 @@ static int nest_imc_event_init(struct perf_event *event)* Get the base memory addresss for this cpu. */ chip_id =cpu_to_chip_id (event->cpu); + +/* Return, if chip_id is not valid */ +if (chip_id <0 ) +return -ENODEV ; + pcni = pmu->mem_info; do { if (pcni->id == chip_id) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 15/167 powerpc/boot: Fix missing check of lseek() return value
In reply to Sasha LevinFrom: Bo YU <[email protected]>
[ Upstream commit 5d085ec04a000fefb5182d3b03ee46ca96d8389b ]
This is detected by Coverity scan: CID: 1440481
--- arch/powerpc/boot/addnote.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/powerpc/boot/addnote.c +5 -1
@@ -223,7 +223,11 @@ main(int ac, char **av)PUT_16 (E_PHNUM , np +2 );/* write back */ -lseek (fd, (long )0 ,SEEK_SET ); + i =lseek (fd, (long )0 ,SEEK_SET ); +if (i <0 ) { +perror ("lseek" ); +exit (1 ); + } i =write (fd, buf, n);if (i <0 ) {perror ("write" );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 16/167 ASoC: imx: fix fiq dependencies
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit ea751227c813ab833609afecfeedaf0aa26f327e ]
During randconfig builds, I occasionally run into an invalid configuration of the freescale FIQ sound support:
WARNING: unmet direct dependencies detected for SND_SOC_IMX_PCM_FIQ
Depends on [m]: SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && SND_IMX_SOC [=m]
Selected by [y]:
- SND_SOC_FSL_SPDIF [=y] && SOUND [=y] && !UML && SND [=y] && SND_SOC [=y] && SND_IMX_SOC [=m]!=n && (MXC_TZIC [=n] || MXC_AVIC [=y])
sound/soc/fsl/imx-ssi.o: In function `imx_ssi_remove':
imx-ssi.c:(.text+0x28): undefined reference to imx_pcm_fiq_exit' sound/soc/fsl/imx-ssi.o: In function imx_ssi_probe':
imx-ssi.c:(.text+0xa64): undefined reference to `imx_pcm_fiq_init'
The Kconfig warning is a result of the symbol being defined inside of the "if SND_IMX_SOC" block, and is otherwise harmless. The link error is more tricky and happens with SND_SOC_IMX_SSI=y, which may or may not imply FIQ support. However, if SND_SOC_FSL_SSI is set to =m at the same time, that selects SND_SOC_IMX_PCM_FIQ as a loadable module dependency, which then causes a link failure from imx-ssi.
The solution here is to make SND_SOC_IMX_PCM_FIQ built-in whenever one of its potential users is built-in.
--- sound/soc/fsl/Kconfig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
sound/soc/fsl/Kconfig +5 -4
@@ -173,16 +173,17 @@ config SND_MPC52xx_SOC_EFIKA endif # SND_POWERPC_SOC +config SND_SOC_IMX_PCM_FIQ + tristate + default y if SND_SOC_IMX_SSI=y && (SND_SOC_FSL_SSI=m || SND_SOC_FSL_SPDIF=m) && (MXC_TZIC || MXC_AVIC) + select FIQ + if SND_IMX_SOC config SND_SOC_IMX_SSI tristate select SND_SOC_FSL_UTILS -config SND_SOC_IMX_PCM_FIQ - tristate - select FIQ - comment "SoC Audio support for Freescale i.MX boards:" config SND_MXC_SOC_WM1133_EV1
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 17/167 spi: pxa2xx: fix SCR (divisor) calculation
In reply to Sasha LevinFrom: Flavio Suligoi <[email protected]>
[ Upstream commit 29f2133717c527f492933b0622a4aafe0b3cbe9e ]
Calculate the divisor for the SCR (Serial Clock Rate), avoiding that the SSP transmission rate can be greater than the device rate.
When the division between the SSP clock and the device rate generates a reminder, we have to increment by one the divisor.
In this way the resulting SSP clock will never be greater than the device SPI max frequency.
For example, with:
- ssp_clk = 50 MHz
- dev freq = 15 MHz
without this patch the SSP clock will be greater than 15 MHz:
- 25 MHz for PXA25x_SSP and CE4100_SSP
- 16,56 MHz for the others
Instead, with this patch, we have in both case an SSP clock of 12.5MHz, so the max rate of the SPI device clock is respected.
--- drivers/spi/spi-pxa2xx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/spi/spi-pxa2xx.c +6 -2
@@ -938,10 +938,14 @@ static unsigned int ssp_get_clk_div(struct driver_data *drv_data, int rate) rate =min_t (int, ssp_clk, rate); +/* +* Calculate the divisor for the SCR (Serial Clock Rate), avoiding +* that the SSP transmission rate can be greater than the device rate +*/ if (ssp->type == PXA25x_SSP || ssp->type ==CE4100_SSP ) -return (ssp_clk / (2 * rate) -1 ) &0xff ; +return (DIV_ROUND_UP (ssp_clk,2 * rate) -1 ) &0xff ;else -return (ssp_clk / rate -1 ) &0xfff ; +return (DIV_ROUND_UP (ssp_clk, rate) -1 ) &0xfff ; } static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 18/167 brcm80211: potential NULL dereference in brcmf_cfg80211_vndr_cmds_dcmd_handler()
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit e025da3d7aa4770bb1d1b3b0aa7cc4da1744852d ]
If "ret_len" is negative then it could lead to a NULL dereference.
The "ret_len" value comes from nl80211_vendor_cmd(), if it's negative then we don't allocate the "dcmd_buf" buffer. Then we pass "ret_len" to brcmf_fil_cmd_data_set() where it is cast to a very high u32 value. Most of the functions in that call tree check whether the buffer we pass is NULL but there are at least a couple places which don't such as brcmf_dbg_hex_dump() and brcmf_msgbuf_query_dcmd(). We memcpy() to and from the buffer so it would result in a NULL dereference.
The fix is to change the types so that "ret_len" can't be negative. (If we memcpy() zero bytes to NULL, that's a no-op and doesn't cause an issue).
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c +3 -2
@@ -35,9 +35,10 @@ static int brcmf_cfg80211_vndr_cmds_dcmd_handler(struct wiphy *wiphy,struct brcmf_if *ifp;const struct brcmf_vndr_dcmd_hdr *cmdhdr = data;struct sk_buff *reply; -int ret, payload, ret_len; +unsigned int payload, ret_len;void *dcmd_buf =NULL , *wr_pointer;u16 msglen, maxmsglen =PAGE_SIZE -0x100 ; +int ret;if (len <sizeof (*cmdhdr)) {brcmf_err ("vendor command too short: %d\n" , len);
@@ -65,7 +66,7 @@ static int brcmf_cfg80211_vndr_cmds_dcmd_handler(struct wiphy *wiphy,brcmf_err ("oversize return buffer %d\n" , ret_len); ret_len =BRCMF_DCMD_MAXLEN ; } - payload =max (ret_len, len) +1 ; + payload = max_t(unsigned int, ret_len, len) + 1; dcmd_buf =vzalloc (payload);if (NULL == dcmd_buf)return -ENOMEM ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 19/167 ACPI / property: fix handling of data_nodes in acpi_get_next_subnode()
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 23583f7795025e3c783b680d906509366b0906ad ]
When the DSDT tables expose devices with subdevices and a set of hierarchical _DSD properties, the data returned by acpi_get_next_subnode() is incorrect, with the results suggesting a bad pointer assignment. The parser works fine with device_nodes or data_nodes, but not with a combination of the two.
The problem is traced to an invalid pointer used when jumping from handling device_nodes to data nodes. The existing code looks for data nodes below the last subdevice found instead of the common root. Fix by forcing the acpi_device pointer to be derived from the same fwnode for the two types of subnodes.
This same problem of handling device and data nodes was already fixed in a similar way by 'commit bf4703fdd166 ("ACPI / property: fix data node parsing in acpi_get_next_subnode()")' but broken later by 'commit 34055190b19 ("ACPI / property: Add fwnode_get_next_child_node()")', so this should probably go to linux-stable all the way to 4.12
--- drivers/acpi/property.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/acpi/property.c +8 -0
@@ -943,6 +943,14 @@ struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,const struct acpi_data_node *data =to_acpi_data_node (fwnode);struct acpi_data_node *dn; +/* +* We can have a combination of device and data nodes, e.g. with +* hierarchical _DSD properties. Make sure the adev pointer is +* restored before going through data nodes, otherwise we will +* be looking for data_nodes below the last device found instead +* of the common fwnode shared by device_nodes and data_nodes. +*/ + adev =to_acpi_device_node (fwnode);if (adev) head = &adev->data.subnodes;else if (data)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 20/167 ARM: vdso: Remove dependency with the arch_timer driver internals
In reply to Sasha LevinFrom: Marc Zyngier <[email protected]>
[ Upstream commit 1f5b62f09f6b314c8d70b9de5182dae4de1f94da ]
The VDSO code uses the kernel helper that was originally designed to abstract the access between 32 and 64bit systems. It worked so far because this function is declared as 'inline'.
As we're about to revamp that part of the code, the VDSO would break. Let's fix it by doing what should have been done from the start, a proper system register access.
--- arch/arm/include/asm/cp15.h | 2 ++ arch/arm/vdso/vgettimeofday.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-)
arch/arm/include/asm/cp15.h +2 -0
@@ -68,6 +68,8 @@#define BPIALL __ACCESS_CP15(c7, 0, c5, 6)#define ICIALLU __ACCESS_CP15(c7, 0, c5, 0) +#define CNTVCT __ACCESS_CP15_64(1, c14) +extern unsigned long cr_alignment;/* defined in entry-armv.S */ static inline unsigned long get_cr (void )
arch/arm/vdso/vgettimeofday.c +3 -2
@@ -18,9 +18,9 @@#include <linux/compiler.h> #include <linux/hrtimer.h> #include <linux/time.h> -#include <asm/arch_timer.h> #include <asm/barrier.h> #include <asm/bug.h> +#include <asm/cp15.h> #include <asm/page.h> #include <asm/unistd.h> #include <asm/vdso_datapage.h>
@@ -123,7 +123,8 @@ static notrace u64 get_ns(struct vdso_data *vdata)u64 cycle_now;u64 nsec; - cycle_now =arch_counter_get_cntvct (); +isb (); + cycle_now =read_sysreg (CNTVCT ); cycle_delta = (cycle_now - vdata->cs_cycle_last) & vdata->cs_mask;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 21/167 arm64: Fix compiler warning from pte_unmap() with -Wunused-but-set-variable
In reply to Sasha LevinFrom: Qian Cai <[email protected]>
[ Upstream commit 74dd022f9e6260c3b5b8d15901d27ebcc5f21eda ]
When building with -Wunused-but-set-variable, the compiler shouts about a number of pte_unmap() users, since this expands to an empty macro on arm64:
| mm/gup.c: In function 'gup_pte_range': | mm/gup.c:1727:16: warning: variable 'ptem' set but not used | [-Wunused-but-set-variable] | mm/gup.c: At top level: | mm/memory.c: In function 'copy_pte_range': | mm/memory.c:821:24: warning: variable 'orig_dst_pte' set but not used | [-Wunused-but-set-variable] | mm/memory.c:821:9: warning: variable 'orig_src_pte' set but not used | [-Wunused-but-set-variable] | mm/swap_state.c: In function 'swap_ra_info': | mm/swap_state.c:641:15: warning: variable 'orig_pte' set but not used | [-Wunused-but-set-variable] | mm/madvise.c: In function 'madvise_free_pte_range': | mm/madvise.c:318:9: warning: variable 'orig_pte' set but not used | [-Wunused-but-set-variable]
Rewrite pte_unmap() as a static inline function, which silences the warnings.
--- arch/arm64/include/asm/pgtable.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/include/asm/pgtable.h +2 -1
@@ -420,6 +420,8 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)return pmd_val (pmd) &PHYS_MASK & (s32 )PAGE_MASK ; } +static inline void pte_unmap (pte_t *pte) { } +/* Find an entry in the third-level page table. */ #define pte_index (addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
@@ -428,7 +430,6 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd)#define pte_offset_map (dir,addr) pte_offset_kernel((dir), (addr))#define pte_offset_map_nested (dir,addr) pte_offset_kernel((dir), (addr)) -#define pte_unmap (pte) do { } while (0)#define pte_unmap_nested (pte) do { } while (0)#define pte_set_fixmap (addr) ((pte_t *)set_fixmap_offset(FIX_PTE, addr))
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 22/167 sched/cpufreq: Fix kobject memleak
In reply to Sasha LevinFrom: Viresh Kumar <[email protected]>
[ Upstream commit 9a4f26cc98d81b67ecc23b890c28e2df324e29f3 ]
Currently the error return path from kobject_init_and_add() is not followed by a call to kobject_put() - which means we are leaking the kobject.
Fix it by adding a call to kobject_put() in the error path of kobject_init_and_add().
--- drivers/cpufreq/cpufreq.c | 1 + drivers/cpufreq/cpufreq_governor.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/cpufreq/cpufreq.c +1 -0
@@ -1101,6 +1101,7 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) cpufreq_global_kobject, "policy%u", cpu);if (ret) {pr_err ("%s: failed to init policy->kobj: %d\n" , __func__, ret); +kobject_put (&policy->kobj); goto err_free_real_cpus; }
drivers/cpufreq/cpufreq_governor.c +2 -0
@@ -459,6 +459,8 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy)/* Failure, so roll back. */ pr_err ("initialization failed (dbs_data kobject init error %d)\n" , ret); +kobject_put (&dbs_data->attr_set.kobj); + policy->governor_data =NULL ;if (!have_governor_per_policy ())
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 23/167 scsi: qla2xxx: Fix a qla24xx_enable_msix() error path
In reply to Sasha LevinFrom: Bart Van Assche <[email protected]>
[ Upstream commit 24afabdbd0b3553963a2bbf465895492b14d1107 ]
Make sure that the allocated interrupts are freed if allocating memory for the msix_entries array fails.
--- drivers/scsi/qla2xxx/qla_isr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_isr.c +5 -1
@@ -3395,7 +3395,7 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)ql_log (ql_log_fatal, vha,0x00c8 ,"Failed to allocate memory for ha->msix_entries.\n" ); ret = -ENOMEM ; - goto msix_out; + goto free_irqs; } ha->flags.msix_enabled =1 ;
@@ -3477,6 +3477,10 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) msix_out:return ret; + +free_irqs: +pci_free_irq_vectors (ha->pdev); + goto msix_out; }int
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 24/167 scsi: qla2xxx: Fix abort handling in tcm_qla2xxx_write_pending()
In reply to Sasha LevinFrom: Bart Van Assche <[email protected]>
[ Upstream commit e209783d66bca04b5fce4429e59338517ffc1a0b ]
Implementations of the .write_pending() callback functions must guarantee that an appropriate LIO core callback function will be called immediately or at a later time. Make sure that this guarantee is met for aborted SCSI commands.
[mkp: typo]
--- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/qla2xxx/tcm_qla2xxx.c +2 -0
@@ -391,6 +391,8 @@ static int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd) cmd->se_cmd.transport_state, cmd->se_cmd.t_state, cmd->se_cmd.se_cmd_flags); +transport_generic_request_failure (&cmd->se_cmd, +TCM_CHECK_CONDITION_ABORT_CMD );return 0 ; } cmd->trc_flags |=TRC_XFR_RDY ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 25/167 scsi: qla2xxx: Avoid that lockdep complains about unsafe locking in tcm_qla2xxx_close_session()
In reply to Sasha LevinFrom: Bart Van Assche <[email protected]>
[ Upstream commit d4023db71108375e4194e92730ba0d32d7f07813 ]
This patch avoids that lockdep reports the following warning:
=====================================================
WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected
5.1.0-rc1-dbg+ #11 Tainted: G W
-----------------------------------------------------
rmdir/1478 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:00000000e7ac4607 (&(&k->k_lock)->rlock){+.+.}, at: klist_next+0x43/0x1d0
and this task is already holding:00000000cf0baf5e (&(&ha->tgt.sess_lock)->rlock){-...}, at: tcm_qla2xxx_close_session+0x57/0xb0 [tcm_qla2xxx] which would create a new lock dependency:
(&(&ha->tgt.sess_lock)->rlock){-...} -> (&(&k->k_lock)->rlock){+.+.}
but this new dependency connects a HARDIRQ-irq-safe lock:
(&(&ha->tgt.sess_lock)->rlock){-...}
... which became HARDIRQ-irq-safe at:
lock_acquire+0xe3/0x200 _raw_spin_lock_irqsave+0x3d/0x60 qla2x00_fcport_event_handler+0x1f3d/0x22b0 [qla2xxx] qla2x00_async_login_sp_done+0x1dc/0x1f0 [qla2xxx] qla24xx_process_response_queue+0xa37/0x10e0 [qla2xxx] qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx] __handle_irq_event_percpu+0x79/0x3c0 handle_irq_event_percpu+0x70/0xf0 handle_irq_event+0x5a/0x8b handle_edge_irq+0x12c/0x310 handle_irq+0x192/0x20a do_IRQ+0x73/0x160 ret_from_intr+0x0/0x1d default_idle+0x23/0x1f0 arch_cpu_idle+0x15/0x20 default_idle_call+0x35/0x40 do_idle+0x2bb/0x2e0 cpu_startup_entry+0x1d/0x20 start_secondary+0x24d/0x2d0 secondary_startup_64+0xa4/0xb0
to a HARDIRQ-irq-unsafe lock:
(&(&k->k_lock)->rlock){+.+.}
... which became HARDIRQ-irq-unsafe at:
...
lock_acquire+0xe3/0x200 _raw_spin_lock+0x32/0x50 klist_add_tail+0x33/0xb0 device_add+0x7f4/0xb60 device_create_groups_vargs+0x11c/0x150 device_create_with_groups+0x89/0xb0 vtconsole_class_init+0xb2/0x124 do_one_initcall+0xc5/0x3ce kernel_init_freeable+0x295/0x32e kernel_init+0x11/0x11b ret_from_fork+0x3a/0x50
other info that might help us debug this:
Possible interrupt unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&(&k->k_lock)->rlock);
local_irq_disable();
lock(&(&ha->tgt.sess_lock)->rlock);
lock(&(&k->k_lock)->rlock);
<Interrupt>
lock(&(&ha->tgt.sess_lock)->rlock);*** DEADLOCK ***
4 locks held by rmdir/1478:
#0: 000000002c7f1ba4 (sb_writers#10){.+.+}, at: mnt_want_write+0x32/0x70
#1: 00000000c85eb147 (&default_group_class[depth - 1]#2/1){+.+.}, at: do_rmdir+0x217/0x2d0
#2: 000000002b164d6f (&sb->s_type->i_mutex_key#13){++++}, at: vfs_rmdir+0x7e/0x1d0
#3: 00000000cf0baf5e (&(&ha->tgt.sess_lock)->rlock){-...}, at: tcm_qla2xxx_close_session+0x57/0xb0 [tcm_qla2xxx]
the dependencies between HARDIRQ-irq-safe lock and the holding lock:
-> (&(&ha->tgt.sess_lock)->rlock){-...} ops: 127 {
IN-HARDIRQ-W at:
lock_acquire+0xe3/0x200
_raw_spin_lock_irqsave+0x3d/0x60
qla2x00_fcport_event_handler+0x1f3d/0x22b0 [qla2xxx]
qla2x00_async_login_sp_done+0x1dc/0x1f0 [qla2xxx]
qla24xx_process_response_queue+0xa37/0x10e0 [qla2xxx]
qla24xx_msix_rsp_q+0x79/0xf0 [qla2xxx]
__handle_irq_event_percpu+0x79/0x3c0
handle_irq_event_percpu+0x70/0xf0
handle_irq_event+0x5a/0x8b
handle_edge_irq+0x12c/0x310
handle_irq+0x192/0x20a
do_IRQ+0x73/0x160
ret_from_intr+0x0/0x1d
default_idle+0x23/0x1f0
arch_cpu_idle+0x15/0x20
default_idle_call+0x35/0x40
do_idle+0x2bb/0x2e0
cpu_startup_entry+0x1d/0x20
start_secondary+0x24d/0x2d0
secondary_startup_64+0xa4/0xb0
INITIAL USE at:
lock_acquire+0xe3/0x200
_raw_spin_lock_irqsave+0x3d/0x60
qla2x00_loop_resync+0xb3d/0x2690 [qla2xxx]
qla2x00_do_dpc+0xcee/0xf30 [qla2xxx]
kthread+0x1d2/0x1f0
ret_from_fork+0x3a/0x50
}
... key at: [<ffffffffa125f700>] __key.62804+0x0/0xfffffffffff7e900 [qla2xxx]
... acquired at:
__lock_acquire+0x11ed/0x1b60
lock_acquire+0xe3/0x200
_raw_spin_lock_irqsave+0x3d/0x60
klist_next+0x43/0x1d0
device_for_each_child+0x96/0x110
scsi_target_block+0x3c/0x40 [scsi_mod]
fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc]
qla2x00_mark_device_lost+0x4d3/0x500 [qla2xxx]
qlt_unreg_sess+0x104/0x2c0 [qla2xxx]
tcm_qla2xxx_close_session+0xa2/0xb0 [tcm_qla2xxx]
target_shutdown_sessions+0x17b/0x190 [target_core_mod]
core_tpg_del_initiator_node_acl+0xf3/0x1f0 [target_core_mod]
target_fabric_nacl_base_release+0x25/0x30 [target_core_mod]
config_item_release+0x9f/0x120 [configfs]
config_item_put+0x29/0x2b [configfs]
configfs_rmdir+0x3d2/0x520 [configfs]
vfs_rmdir+0xb3/0x1d0
do_rmdir+0x25c/0x2d0
__x64_sys_rmdir+0x24/0x30
do_syscall_64+0x77/0x220
entry_SYSCALL_64_after_hwframe+0x49/0xbethe dependencies between the lock to be acquired
and HARDIRQ-irq-unsafe lock:
-> (&(&k->k_lock)->rlock){+.+.} ops: 14568 {
HARDIRQ-ON-W at:
lock_acquire+0xe3/0x200
_raw_spin_lock+0x32/0x50
klist_add_tail+0x33/0xb0
device_add+0x7f4/0xb60
device_create_groups_vargs+0x11c/0x150
device_create_with_groups+0x89/0xb0
vtconsole_class_init+0xb2/0x124
do_one_initcall+0xc5/0x3ce
kernel_init_freeable+0x295/0x32e
kernel_init+0x11/0x11b
ret_from_fork+0x3a/0x50
SOFTIRQ-ON-W at:
lock_acquire+0xe3/0x200
_raw_spin_lock+0x32/0x50
klist_add_tail+0x33/0xb0
device_add+0x7f4/0xb60
device_create_groups_vargs+0x11c/0x150
device_create_with_groups+0x89/0xb0
vtconsole_class_init+0xb2/0x124
do_one_initcall+0xc5/0x3ce
kernel_init_freeable+0x295/0x32e
kernel_init+0x11/0x11b
ret_from_fork+0x3a/0x50
INITIAL USE at:
lock_acquire+0xe3/0x200
_raw_spin_lock+0x32/0x50
klist_add_tail+0x33/0xb0
device_add+0x7f4/0xb60
device_create_groups_vargs+0x11c/0x150
device_create_with_groups+0x89/0xb0
vtconsole_class_init+0xb2/0x124
do_one_initcall+0xc5/0x3ce
kernel_init_freeable+0x295/0x32e
kernel_init+0x11/0x11b
ret_from_fork+0x3a/0x50
}
... key at: [<ffffffff83f3d900>] __key.15805+0x0/0x40
... acquired at:
__lock_acquire+0x11ed/0x1b60
lock_acquire+0xe3/0x200
_raw_spin_lock_irqsave+0x3d/0x60
klist_next+0x43/0x1d0
device_for_each_child+0x96/0x110
scsi_target_block+0x3c/0x40 [scsi_mod]
fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc]
qla2x00_mark_device_lost+0x4d3/0x500 [qla2xxx]
qlt_unreg_sess+0x104/0x2c0 [qla2xxx]
tcm_qla2xxx_close_session+0xa2/0xb0 [tcm_qla2xxx]
target_shutdown_sessions+0x17b/0x190 [target_core_mod]
core_tpg_del_initiator_node_acl+0xf3/0x1f0 [target_core_mod]
target_fabric_nacl_base_release+0x25/0x30 [target_core_mod]
config_item_release+0x9f/0x120 [configfs]
config_item_put+0x29/0x2b [configfs]
configfs_rmdir+0x3d2/0x520 [configfs]
vfs_rmdir+0xb3/0x1d0
do_rmdir+0x25c/0x2d0
__x64_sys_rmdir+0x24/0x30
do_syscall_64+0x77/0x220
entry_SYSCALL_64_after_hwframe+0x49/0xbe
stack backtrace:
CPU: 7 PID: 1478 Comm: rmdir Tainted: G W 5.1.0-rc1-dbg+ #11
Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Call Trace:
dump_stack+0x86/0xca
check_usage.cold.59+0x473/0x563
check_prev_add.constprop.43+0x1f1/0x1170
__lock_acquire+0x11ed/0x1b60
lock_acquire+0xe3/0x200
_raw_spin_lock_irqsave+0x3d/0x60
klist_next+0x43/0x1d0
device_for_each_child+0x96/0x110
scsi_target_block+0x3c/0x40 [scsi_mod]
fc_remote_port_delete+0xe7/0x1c0 [scsi_transport_fc]
qla2x00_mark_device_lost+0x4d3/0x500 [qla2xxx]
qlt_unreg_sess+0x104/0x2c0 [qla2xxx]
tcm_qla2xxx_close_session+0xa2/0xb0 [tcm_qla2xxx]
target_shutdown_sessions+0x17b/0x190 [target_core_mod]
core_tpg_del_initiator_node_acl+0xf3/0x1f0 [target_core_mod]
target_fabric_nacl_base_release+0x25/0x30 [target_core_mod]
config_item_release+0x9f/0x120 [configfs]
config_item_put+0x29/0x2b [configfs]
configfs_rmdir+0x3d2/0x520 [configfs]
vfs_rmdir+0xb3/0x1d0
do_rmdir+0x25c/0x2d0
__x64_sys_rmdir+0x24/0x30
do_syscall_64+0x77/0x220
entry_SYSCALL_64_after_hwframe+0x49/0xbe--- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/tcm_qla2xxx.c +2 -1
@@ -366,8 +366,9 @@ static void tcm_qla2xxx_close_session(struct se_session *se_sess)spin_lock_irqsave (&vha->hw->tgt.sess_lock, flags);target_sess_cmd_list_set_waiting (se_sess); -tcm_qla2xxx_put_sess (sess);spin_unlock_irqrestore (&vha->hw->tgt.sess_lock, flags); + +tcm_qla2xxx_put_sess (sess); }static u32 tcm_qla2xxx_sess_get_index (struct se_session *se_sess)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 26/167 Btrfs: fix data bytes_may_use underflow with fallocate due to failed quota reserve
In reply to Sasha LevinFrom: Robbie Ko <[email protected]>
[ Upstream commit 39ad317315887c2cb9a4347a93a8859326ddf136 ]
When doing fallocate, we first add the range to the reserve_list and then reserve the quota. If quota reservation fails, we'll release all reserved parts of reserve_list.
However, cur_offset is not updated to indicate that this range is already been inserted into the list. Therefore, the same range is freed twice. Once at list_for_each_entry loop, and once at the end of the function. This will result in WARN_ON on bytes_may_use when we free the remaining space.
At the end, under the 'out' label we have a call to:
btrfs_free_reserved_data_space(inode, data_reserved, alloc_start, alloc_end - cur_offset);
The start offset, third argument, should be cur_offset.
Everything from alloc_start to cur_offset was freed by the list_for_each_entry_safe_loop.
--- fs/btrfs/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/file.c +2 -1
@@ -2964,6 +2964,7 @@ static long btrfs_fallocate(struct file *file, int mode, ret =btrfs_qgroup_reserve_data (inode, &data_reserved, cur_offset, last_byte - cur_offset);if (ret <0 ) { + cur_offset = last_byte;free_extent_map (em);break ; }
@@ -3034,7 +3035,7 @@ static long btrfs_fallocate(struct file *file, int mode,/* Let go of our reservation. */ if (ret !=0 )btrfs_free_reserved_data_space (inode, data_reserved, - alloc_start, alloc_end - cur_offset); + cur_offset, alloc_end - cur_offset);extent_changeset_free (data_reserved);return ret; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 27/167 btrfs: fix panic during relocation after ENOSPC before writeback happens
In reply to Sasha LevinFrom: Josef Bacik <[email protected]>
[ Upstream commit ff612ba7849964b1898fd3ccd1f56941129c6aab ]
We've been seeing the following sporadically throughout our fleet
panic: kernel BUG at fs/btrfs/relocation.c:4584!
netversion: 5.0-0
Backtrace:
#0 [ffffc90003adb880] machine_kexec at ffffffff81041da8
#1 [ffffc90003adb8c8] __crash_kexec at ffffffff8110396c
#2 [ffffc90003adb988] crash_kexec at ffffffff811048ad
#3 [ffffc90003adb9a0] oops_end at ffffffff8101c19a
#4 [ffffc90003adb9c0] do_trap at ffffffff81019114
#5 [ffffc90003adba00] do_error_trap at ffffffff810195d0
#6 [ffffc90003adbab0] invalid_op at ffffffff81a00a9b
[exception RIP: btrfs_reloc_cow_block+692]
RIP: ffffffff8143b614 RSP: ffffc90003adbb68 RFLAGS: 00010246
RAX: fffffffffffffff7 RBX: ffff8806b9c32000 RCX: ffff8806aad00690
RDX: ffff880850b295e0 RSI: ffff8806b9c32000 RDI: ffff88084f205bd0
RBP: ffff880849415000 R8: ffffc90003adbbe0 R9: ffff88085ac90000
R10: ffff8805f7369140 R11: 0000000000000000 R12: ffff880850b295e0
R13: ffff88084f205bd0 R14: 0000000000000000 R15: 0000000000000000
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
#7 [ffffc90003adbbb0] __btrfs_cow_block at ffffffff813bf1cd
#8 [ffffc90003adbc28] btrfs_cow_block at ffffffff813bf4b3
#9 [ffffc90003adbc78] btrfs_search_slot at ffffffff813c2e6cThe way relocation moves data extents is by creating a reloc inode and preallocating extents in this inode and then copying the data into these preallocated extents. Once we've done this for all of our extents, we'll write out these dirty pages, which marks the extent written, and goes into btrfs_reloc_cow_block(). From here we get our current reloc_control, which _should_ match the reloc_control for the current block group we're relocating.
However if we get an ENOSPC in this path at some point we'll bail out, never initiating writeback on this inode. Not a huge deal, unless we happen to be doing relocation on a different block group, and this block group is now rc->stage == UPDATE_DATA_PTRS. This trips the BUG_ON() in btrfs_reloc_cow_block(), because we expect to be done modifying the data inode. We are in fact done modifying the metadata for the data inode we're currently using, but not the one from the failed block group, and thus we BUG_ON().
(This happens when writeback finishes for extents from the previous group, when we are at btrfs_finish_ordered_io() which updates the data reloc tree (inode item, drops/adds extent items, etc).)
Fix this by writing out the reloc data inode always, and then breaking out of the loop after that point to keep from tripping this BUG_ON() later.
--- fs/btrfs/relocation.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
fs/btrfs/relocation.c +20 -11
@@ -4403,27 +4403,36 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)mutex_lock (&fs_info->cleaner_mutex); ret =relocate_block_group (rc);mutex_unlock (&fs_info->cleaner_mutex); -if (ret <0 ) { +if (ret <0 ) err = ret; - goto out; - } - -if (rc->extents_found ==0 ) -break ; - -btrfs_info (fs_info,"found %llu extents" , rc->extents_found); +/* +* We may have gotten ENOSPC after we already dirtied some +* extents. If writeout happens while we're relocating a +* different block group we could end up hitting the +* BUG_ON(rc->stage == UPDATE_DATA_PTRS) in +* btrfs_reloc_cow_block. Make sure we write everything out +* properly so we don't trip over this problem, and then break +* out of the loop if we hit an error. +*/ if (rc->stage ==MOVE_DATA_EXTENTS && rc->found_file_extent) { ret =btrfs_wait_ordered_range (rc->data_inode,0 , (u64)-1 ); -if (ret) { +if (ret) err = ret; - goto out; - }invalidate_mapping_pages (rc->data_inode->i_mapping,0 ,-1 ); rc->stage =UPDATE_DATA_PTRS ; } + +if (err <0 ) + goto out; + +if (rc->extents_found ==0 ) +break ; + +btrfs_info (fs_info,"found %llu extents" , rc->extents_found); + }WARN_ON (rc->block_group->pinned >0 );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 28/167 btrfs: Don't panic when we can't find a root key
In reply to Sasha LevinFrom: Qu Wenruo <[email protected]>
[ Upstream commit 7ac1e464c4d473b517bb784f30d40da1f842482e ]
When we failed to find a root key in btrfs_update_root(), we just panic.
That's definitely not cool, fix it by outputting an unique error message, aborting current transaction and return -EUCLEAN. This should not normally happen as the root has been used by the callers in some way.
--- fs/btrfs/root-tree.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
fs/btrfs/root-tree.c +8 -5
@@ -150,11 +150,14 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root goto out; } -if (ret !=0 ) { -btrfs_print_leaf (path->nodes[0 ]); -btrfs_crit (fs_info,"unable to update root key %llu %u %llu" , - key->objectid, key->type, key->offset); -BUG_ON (1 ); +if (ret >0 ) { +btrfs_crit (fs_info, +"unable to find root key (%llu %u %llu) in tree %llu" , + key->objectid, key->type, key->offset, + root->root_key.objectid); + ret = -EUCLEAN ; +btrfs_abort_transaction (trans, ret); + goto out; } l = path->nodes[0 ];
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 29/167 iwlwifi: pcie: don't crash on invalid RX interrupt
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit 30f24eabab8cd801064c5c37589d803cb4341929 ]
If for some reason the device gives us an RX interrupt before we're ready for it, perhaps during device power-on with misconfigured IRQ causes mapping or so, we can crash trying to access the queues.
Prevent that by checking that we actually have RXQs and that they were properly allocated.
--- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/pcie/rx.c +6 -1
@@ -1252,10 +1252,15 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans,static void iwl_pcie_rx_handle (struct iwl_trans *trans,int queue) {struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); -struct iwl_rxq *rxq = &trans_pcie->rxq[queue]; +struct iwl_rxq *rxq;u32 r, i, count =0 ;bool emergency = false; +if (WARN_ON_ONCE (!trans_pcie->rxq || !trans_pcie->rxq[queue].bd)) +return ; + + rxq = &trans_pcie->rxq[queue]; + restart:spin_lock (&rxq->lock);/* uCode's read index (stored in shared DRAM) indicates the last Rx
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 30/167 rtc: 88pm860x: prevent use-after-free on device remove
In reply to Sasha LevinFrom: Sven Van Asbroeck <[email protected]>
[ Upstream commit f22b1ba15ee5785aa028384ebf77dd39e8e47b70 ]
The device's remove() attempts to shut down the delayed_work scheduled on the kernel-global workqueue by calling flush_scheduled_work().
Unfortunately, flush_scheduled_work() does not prevent the delayed_work from re-scheduling itself. The delayed_work might run after the device has been removed, and touch the already de-allocated info structure. This is a potential use-after-free.
Fix by calling cancel_delayed_work_sync() during remove(): this ensures that the delayed work is properly cancelled, is no longer running, and is not able to re-schedule itself.
This issue was detected with the help of Coccinelle.
--- drivers/rtc/rtc-88pm860x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-88pm860x.c +1 -1
@@ -414,7 +414,7 @@ static int pm860x_rtc_remove(struct platform_device *pdev)struct pm860x_rtc_info *info =platform_get_drvdata (pdev);#ifdef VRTC_CALIBRATION -flush_scheduled_work (); +cancel_delayed_work_sync (&info->calib_work);/* disable measurement */ pm860x_set_bits (info->i2c,PM8607_MEAS_EN2 ,MEAS2_VRTC ,0 );#endif /* VRTC_CALIBRATION */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 31/167 scsi: qedi: Abort ep termination if offload not scheduled
In reply to Sasha LevinFrom: Manish Rangankar <[email protected]>
[ Upstream commit f848bfd8e167210a29374e8a678892bed591684f ]
Sometimes during connection recovery when there is a failure to resolve ARP, and offload connection was not issued, driver tries to flush pending offload connection work which was not queued up.
kernel: WARNING: CPU: 19 PID: 10110 at kernel/workqueue.c:3030 __flush_work.isra.34+0x19c/0x1b0
kernel: CPU: 19 PID: 10110 Comm: iscsid Tainted: G W 5.1.0-rc4 #11
kernel: Hardware name: Dell Inc. PowerEdge R730/0599V5, BIOS 2.9.1 12/04/2018
kernel: RIP: 0010:__flush_work.isra.34+0x19c/0x1b0
kernel: Code: 8b fb 66 0f 1f 44 00 00 31 c0 eb ab 48 89 ef c6 07 00 0f 1f 40 00 fb 66 0f 1f 44 00 00 31 c0 eb 96 e8 08 16 fe ff 0f 0b eb 8d <0f> 0b 31 c0 eb 87 0f 1f 40 00 66 2e 0f 1 f 84 00 00 00 00 00 0f 1f
kernel: RSP: 0018:ffffa6b4054dba68 EFLAGS: 00010246
kernel: RAX: 0000000000000000 RBX: ffff91df21c36fc0 RCX: 0000000000000000
kernel: RDX: 0000000000000001 RSI: 0000000000000000 RDI: ffff91df21c36fc0
kernel: RBP: ffff91df21c36ef0 R08: 0000000000000000 R09: 0000000000000000
kernel: R10: 0000000000000038 R11: ffffa6b4054dbd60 R12: ffffffffc05e72c0
kernel: R13: ffff91db10280820 R14: 0000000000000048 R15: 0000000000000000
kernel: FS: 00007f5d83cc1740(0000) GS:ffff91df2f840000(0000) knlGS:0000000000000000
kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
kernel: CR2: 0000000001cc5000 CR3: 0000000465450002 CR4: 00000000001606e0
kernel: Call Trace:
kernel: ? try_to_del_timer_sync+0x4d/0x80
kernel: qedi_ep_disconnect+0x3b/0x410 [qedi]
kernel: ? 0xffffffffc083c000
kernel: ? klist_iter_exit+0x14/0x20
kernel: ? class_find_device+0x93/0xf0
kernel: iscsi_if_ep_disconnect.isra.18+0x58/0x70 [scsi_transport_iscsi]
kernel: iscsi_if_recv_msg+0x10e2/0x1510 [scsi_transport_iscsi]
kernel: ? copyout+0x22/0x30
kernel: ? _copy_to_iter+0xa0/0x430
kernel: ? _cond_resched+0x15/0x30
kernel: ? __kmalloc_node_track_caller+0x1f9/0x270
kernel: iscsi_if_rx+0xa5/0x1e0 [scsi_transport_iscsi]
kernel: netlink_unicast+0x17f/0x230
kernel: netlink_sendmsg+0x2d2/0x3d0
kernel: sock_sendmsg+0x36/0x50
kernel: ___sys_sendmsg+0x280/0x2a0
kernel: ? timerqueue_add+0x54/0x80
kernel: ? enqueue_hrtimer+0x38/0x90
kernel: ? hrtimer_start_range_ns+0x19f/0x2c0
kernel: __sys_sendmsg+0x58/0xa0
kernel: do_syscall_64+0x5b/0x180
kernel: entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- drivers/scsi/qedi/qedi_iscsi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/qedi/qedi_iscsi.c +3 -0
@@ -1008,6 +1008,9 @@ static void qedi_ep_disconnect(struct iscsi_endpoint *ep) qedi_ep = ep->dd_data; qedi = qedi_ep->qedi; +if (qedi_ep->state ==EP_STATE_OFLDCONN_START ) + goto ep_exit_recover; +flush_work (&qedi_ep->offload_work);if (qedi_ep->conn) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 32/167 w1: fix the resume command API
In reply to Sasha LevinFrom: Mariusz Bialonczyk <[email protected]>
[ Upstream commit 62909da8aca048ecf9fbd7e484e5100608f40a63 ]
Quoted 1 line
From the DS2408 datasheet [1]:
"Resume Command function checks the status of the RC flag and, if it is set,
directly transfers control to the control functions, similar to a Skip ROM command. The only way to set the RC flag is through successfully executing the Match ROM, Search ROM, Conditional Search ROM, or Overdrive-Match ROM command"
The function currently works perfectly fine in a multidrop bus, but when we have only a single slave connected, then only a Skip ROM is used and Match ROM is not called at all. This is leading to problems e.g. with single one DS2408 connected, as the Resume Command is not working properly and the device is responding with failing results after the Resume Command.
This commit is fixing this by using a Skip ROM instead in those cases. The bandwidth / performance advantage is exactly the same.
Refs:
[1] https://datasheets.maximintegrated.com/en/ds/DS2408.pdf
--- drivers/w1/w1_io.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/w1/w1_io.c +1 -2
@@ -430,8 +430,7 @@ int w1_reset_resume_command(struct w1_master *dev)if (w1_reset_bus (dev))return -1 ; -/* This will make only the last matched slave perform a skip ROM. */ -w1_write_8 (dev,W1_RESUME_CMD ); +w1_write_8 (dev, dev->slave_count >1 ?W1_RESUME_CMD :W1_SKIP_ROM );return 0 ; }EXPORT_SYMBOL_GPL (w1_reset_resume_command);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 33/167 dmaengine: pl330: _stop: clear interrupt status
In reply to Sasha LevinFrom: Sugar Zhang <[email protected]>
[ Upstream commit 2da254cc7908105a60a6bb219d18e8dced03dcb9 ]
This patch kill instructs the DMAC to immediately terminate execution of a thread. and then clear the interrupt status, at last, stop generating interrupts for DMA_SEV. to guarantee the next dma start is clean. otherwise, one interrupt maybe leave to next start and make some mistake.
we can reporduce the problem as follows:
DMASEV: modify the event-interrupt resource, and if the INTEN sets function as interrupt, the DMAC will set irq<event_num> HIGH to generate interrupt. write INTCLR to clear interrupt.
DMA EXECUTING INSTRUCTS DMA TERMINATE | | | | ... _stop | | | spin_lock_irqsave DMASEV | | | | mask INTEN | | | DMAKILL | | | spin_unlock_irqrestore
in above case, a interrupt was left, and if we unmask INTEN, the DMAC will set irq<event_num> HIGH to generate interrupt.
to fix this, do as follows:
DMA EXECUTING INSTRUCTS DMA TERMINATE | | | | ... _stop | | | spin_lock_irqsave DMASEV | | | | DMAKILL | | | clear INTCLR | mask INTEN | | | spin_unlock_irqrestore
--- drivers/dma/pl330.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/dma/pl330.c +7 -3
@@ -960,6 +960,7 @@ static void _stop(struct pl330_thread *thrd) {void __iomem *regs = thrd->dmac->base;u8 insn[6 ] = {0 ,0 ,0 ,0 ,0 ,0 }; +u32 inten =readl (regs +INTEN );if (_state (thrd) ==PL330_STATE_FAULT_COMPLETING )UNTIL (thrd,PL330_STATE_FAULTING |PL330_STATE_KILLING );
@@ -972,10 +973,13 @@ static void _stop(struct pl330_thread *thrd)_emit_KILL (0 , insn); -/* Stop generating interrupts for SEV */ -writel (readl (regs +INTEN ) & ~(1 << thrd->ev), regs +INTEN ); -_execute_DBGINSN (thrd, insn,is_manager (thrd)); + +/* clear the event */ +if (inten & (1 << thrd->ev)) +writel (1 << thrd->ev, regs +INTCLR ); +/* Stop generating interrupts for SEV */ +writel (inten & ~(1 << thrd->ev), regs +INTEN ); }/* Start doing req 'idx' of thread 'thrd' */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 34/167 mac80211/cfg80211: update bss channel on channel switch
In reply to Sasha LevinFrom: Sergey Matyukevich <[email protected]>
[ Upstream commit 5dc8cdce1d722c733f8c7af14c5fb595cfedbfa8 ]
FullMAC STAs have no way to update bss channel after CSA channel switch completion. As a result, user-space tools may provide inconsistent channel info. For instance, consider the following two commands:
$ sudo iw dev wlan0 link $ sudo iw dev wlan0 info The latter command gets channel info from the hardware, so most probably its output will be correct. However the former command gets channel info from scan cache, so its output will contain outdated channel info. In fact, current bss channel info will not be updated until the next [re-]connect.
Note that mac80211 STAs have a workaround for this, but it requires access to internal cfg80211 data, see ieee80211_chswitch_work:
/* XXX: shouldn't really modify cfg80211-owned data! */ ifmgd->associated->channel = sdata->csa_chandef.chan;
This patch suggests to convert mac80211 workaround into cfg80211 behavior and to update current bss channel in cfg80211_ch_switch_notify.
--- net/mac80211/mlme.c | 3 --- net/wireless/nl80211.c | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-)
net/mac80211/mlme.c +0 -3
@@ -1071,9 +1071,6 @@ static void ieee80211_chswitch_work(struct work_struct *work) goto out; } -/* XXX: shouldn't really modify cfg80211-owned data! */ - ifmgd->associated->channel = sdata->csa_chandef.chan; - ifmgd->csa_waiting_bcn = true;ieee80211_sta_reset_beacon_monitor (sdata);
net/wireless/nl80211.c +5 -0
@@ -14706,6 +14706,11 @@ void cfg80211_ch_switch_notify(struct net_device *dev, wdev->chandef = *chandef; wdev->preset_chandef = *chandef; + +if (wdev->iftype ==NL80211_IFTYPE_STATION && + !WARN_ON (!wdev->current_bss)) + wdev->current_bss->pub.channel = chandef->chan; +nl80211_ch_switch_notify (rdev, dev, chandef,GFP_KERNEL ,NL80211_CMD_CH_SWITCH_NOTIFY ,0 ); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 35/167 libbpf: fix samples/bpf build failure due to undefined UINT32_MAX
In reply to Sasha LevinFrom: "Daniel T. Lee" <[email protected]>
[ Upstream commit 32e621e55496a0009f44fe4914cd4a23cade4984 ]
Currently, building bpf samples will cause the following error.
./tools/lib/bpf/bpf.h:132:27: error: 'UINT32_MAX' undeclared here (not in a function) ..
#define BPF_LOG_BUF_SIZE (UINT32_MAX >> 8) /* verifier maximum in kernels <= 5.1 */
^
./samples/bpf/bpf_load.h:31:25: note: in expansion of macro 'BPF_LOG_BUF_SIZE'
extern char bpf_log_buf[BPF_LOG_BUF_SIZE];
^~~~~~~~~~~~~~~~Due to commit 4519efa6f8ea ("libbpf: fix BPF_LOG_BUF_SIZE off-by-one error") hard-coded size of BPF_LOG_BUF_SIZE has been replaced with UINT32_MAX which is defined in <stdint.h> header.
Even with this change, bpf selftests are running fine since these are built with clang and it includes header(-idirafter) from clang/6.0.0/include. (it has <stdint.h>)
clang -I. -I./include/uapi -I../../../include/uapi -idirafter /usr/local/include -idirafter /usr/include \
-idirafter /usr/lib/llvm-6.0/lib/clang/6.0.0/include -idirafter /usr/include/x86_64-linux-gnu \
-Wno-compare-distinct-pointer-types -O2 -target bpf -emit-llvm -c progs/test_sysctl_prog.c -o - | \
llc -march=bpf -mcpu=generic -filetype=obj -o /linux/tools/testing/selftests/bpf/test_sysctl_prog.oBut bpf samples are compiled with GCC, and it only searches and includes headers declared at the target file. As '#include <stdint.h>' hasn't been declared in tools/lib/bpf/bpf.h, it causes build failure of bpf samples.
gcc -Wp,-MD,./samples/bpf/.sockex3_user.o.d -Wall -Wmissing-prototypes -Wstrict-prototypes \
-O2 -fomit-frame-pointer -std=gnu89 -I./usr/include -I./tools/lib/ -I./tools/testing/selftests/bpf/ \
-I./tools/ lib/ -I./tools/include -I./tools/perf -c -o ./samples/bpf/sockex3_user.o ./samples/bpf/sockex3_user.c;This commit add declaration of '#include <stdint.h>' to tools/lib/bpf/bpf.h to fix this problem.
--- tools/lib/bpf/bpf.h | 1 + 1 file changed, 1 insertion(+)
tools/lib/bpf/bpf.h +1 -0
@@ -23,6 +23,7 @@#include <linux/bpf.h> #include <stddef.h> +#include <stdint.h> int bpf_create_map_node(enum bpf_map_type map_type, int key_size, int value_size, int max_entries, __u32 map_flags,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 36/167 driver core: platform: Fix the usage of platform device name(pdev->name)
In reply to Sasha LevinFrom: Venkata Narendra Kumar Gutta <[email protected]>
[ Upstream commit edb16da34b084c66763f29bee42b4e6bb33c3d66 ]
Platform core is using pdev->name as the platform device name to do the binding of the devices with the drivers. But, when the platform driver overrides the platform device name with dev_set_name(), the pdev->name is pointing to a location which is freed and becomes an invalid parameter to do the binding match.
use-after-free instance:
[ 33.325013] BUG: KASAN: use-after-free in strcmp+0x8c/0xb0 [ 33.330646] Read of size 1 at addr ffffffc10beae600 by task modprobe [ 33.339068] CPU: 5 PID: 518 Comm: modprobe Tainted: G S W O 4.19.30+ #3 [ 33.346835] Hardware name: MTP (DT) [ 33.350419] Call trace: [ 33.352941] dump_backtrace+0x0/0x3b8 [ 33.356713] show_stack+0x24/0x30 [ 33.360119] dump_stack+0x160/0x1d8 [ 33.363709] print_address_description+0x84/0x2e0 [ 33.368549] kasan_report+0x26c/0x2d0 [ 33.372322] __asan_report_load1_noabort+0x2c/0x38 [ 33.377248] strcmp+0x8c/0xb0 [ 33.380306] platform_match+0x70/0x1f8 [ 33.384168] __driver_attach+0x78/0x3a0 [ 33.388111] bus_for_each_dev+0x13c/0x1b8 [ 33.392237] driver_attach+0x4c/0x58 [ 33.395910] bus_add_driver+0x350/0x560 [ 33.399854] driver_register+0x23c/0x328 [ 33.403886] __platform_driver_register+0xd0/0xe0
So, use dev_name(&pdev->dev), which fetches the platform device name from the kobject(dev->kobj->name) of the device instead of the pdev->name.
--- drivers/base/platform.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/base/platform.c +4 -4
@@ -855,7 +855,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a,if (len != -ENODEV )return len; - len =snprintf (buf,PAGE_SIZE ,"platform:%s\n" , pdev->name); + len =snprintf (buf,PAGE_SIZE ,"platform:%s\n" ,dev_name (&pdev->dev));return (len >=PAGE_SIZE ) ? (PAGE_SIZE -1 ) : len; }
@@ -931,7 +931,7 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)return rc;add_uevent_var (env,"MODALIAS=%s%s" ,PLATFORM_MODULE_PREFIX , - pdev->name); +dev_name (&pdev->dev));return 0 ; }
@@ -940,7 +940,7 @@ static const struct platform_device_id *platform_match_id( struct platform_device *pdev) {while (id->name[0 ]) { -if (strcmp (pdev->name, id->name) ==0 ) { +if (strcmp (dev_name (&pdev->dev), id->name) ==0 ) { pdev->id_entry = id;return id; }
@@ -984,7 +984,7 @@ static int platform_match(struct device *dev, struct device_driver *drv)return platform_match_id (pdrv->id_table, pdev) !=NULL ;/* fall-back to driver name match */ -return (strcmp (pdev->name, drv->name) ==0 ); +return (strcmp (dev_name (&pdev->dev), drv->name) ==0 ); }#ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerRe: [PATCH AUTOSEL 4.14 036/167] driver core: platform: Fix the usage of platform device name(pdev->name)
Quoted 36 lines · Sasha Levin
From: Venkata Narendra Kumar Gutta <[email protected]>
[ Upstream commit
edb16da34b084c66763f29bee42b4e6bb33c3d66]Platform core is using
pdev->nameas the platform device name to do the binding of the devices with the drivers. But, when the platform driver overrides the platform device name withdev_set_name(), thepdev->nameis pointing to a location which is freed and becomes an invalid parameter to do the binding match.use-after-free instance:
[ 33.325013] BUG: KASAN: use-after-free in strcmp+0x8c/0xb0 [ 33.330646] Read of size 1 at addr ffffffc10beae600 by task modprobe [ 33.339068] CPU: 5 PID: 518 Comm: modprobe Tainted: G S W O 4.19.30+ #3 [ 33.346835] Hardware name: MTP (DT) [ 33.350419] Call trace: [ 33.352941] dump_backtrace+0x0/0x3b8 [ 33.356713] show_stack+0x24/0x30 [ 33.360119] dump_stack+0x160/0x1d8 [ 33.363709] print_address_description+0x84/0x2e0 [ 33.368549] kasan_report+0x26c/0x2d0 [ 33.372322] __asan_report_load1_noabort+0x2c/0x38 [ 33.377248] strcmp+0x8c/0xb0 [ 33.380306] platform_match+0x70/0x1f8 [ 33.384168] __driver_attach+0x78/0x3a0 [ 33.388111] bus_for_each_dev+0x13c/0x1b8 [ 33.392237] driver_attach+0x4c/0x58 [ 33.395910] bus_add_driver+0x350/0x560 [ 33.399854] driver_register+0x23c/0x328 [ 33.403886] __platform_driver_register+0xd0/0xe0So, use
dev_name(&pdev->dev), which fetches the platform device name from thekobject(dev->kobj->name)of the device instead of thepdev->name.
Quoted 6 lines
Signed-off-by Venkata Narendra Kumar Gutta <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/base/platform.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Again, please just drop from everywhere.
thanks,
greg k-h
Sasha Levin
maintainerPATCH 37/167 ASoC: fsl_sai: Update is_slave_mode with correct value
In reply to Sasha LevinFrom: Daniel Baluta <[email protected]>
[ Upstream commit ddb351145a967ee791a0fb0156852ec2fcb746ba ]
is_slave_mode defaults to false because sai structure that contains it is kzalloc'ed.
Anyhow, if we decide to set the following configuration SAI slave -> SAI master, is_slave_mode will remain set on true although SAI being master it should be set to false.
Fix this by updating is_slave_mode for each call of fsl_sai_set_dai_fmt.
--- sound/soc/fsl/fsl_sai.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/fsl/fsl_sai.c +2 -0
@@ -274,12 +274,14 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,case SND_SOC_DAIFMT_CBS_CFS : val_cr2 |=FSL_SAI_CR2_BCD_MSTR ; val_cr4 |=FSL_SAI_CR4_FSD_MSTR ; + sai->is_slave_mode = false;break ;case SND_SOC_DAIFMT_CBM_CFM : sai->is_slave_mode = true;break ;case SND_SOC_DAIFMT_CBS_CFM : val_cr2 |=FSL_SAI_CR2_BCD_MSTR ; + sai->is_slave_mode = false;break ;case SND_SOC_DAIFMT_CBM_CFS : val_cr4 |=FSL_SAI_CR4_FSD_MSTR ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 38/167 mwifiex: prevent an array overflow
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
[ Upstream commit b4c35c17227fe437ded17ce683a6927845f8c4a4 ]
The "rate_index" is only used as an index into the phist_data->rx_rate[] array in the mwifiex_hist_data_set() function. That array has MWIFIEX_MAX_AC_RX_RATES (74) elements and it's used to generate some debugfs information. The "rate_index" variable comes from the network skb->data[] and it is a u8 so it's in the 0-255 range. We need to cap it to prevent an array overflow.
--- drivers/net/wireless/marvell/mwifiex/cfp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/marvell/mwifiex/cfp.c +3 -0
@@ -531,5 +531,8 @@ u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv, rate_index = (rx_rate >MWIFIEX_RATE_INDEX_OFDM0 ) ? rx_rate -1 : rx_rate; +if (rate_index >=MWIFIEX_MAX_AC_RX_RATES ) + rate_index =MWIFIEX_MAX_AC_RX_RATES -1 ; +return rate_index; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 39/167 net: cw1200: fix a NULL pointer dereference
In reply to Sasha LevinFrom: Kangjie Lu <[email protected]>
[ Upstream commit 0ed2a005347400500a39ea7c7318f1fea57fb3ca ]
In case create_singlethread_workqueue fails, the fix free the hardware and returns NULL to avoid NULL pointer dereference.
--- drivers/net/wireless/st/cw1200/main.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/st/cw1200/main.c +5 -0
@@ -345,6 +345,11 @@ static struct ieee80211_hw *cw1200_init_common(const u8 *macaddr,mutex_init (&priv->wsm_cmd_mux);mutex_init (&priv->conf_mutex); priv->workqueue =create_singlethread_workqueue ("cw1200_wq" ); +if (!priv->workqueue) { +ieee80211_free_hw (hw); +return NULL ; + } +sema_init (&priv->scan.lock,1 );INIT_WORK (&priv->scan.work, cw1200_scan_work);INIT_DELAYED_WORK (&priv->scan.probe_work, cw1200_probe_work);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 40/167 at76c50x-usb: Don't register led_trigger if usb_register_driver failed
In reply to Sasha LevinFrom: YueHaibing <[email protected]>
[ Upstream commit 09ac2694b0475f96be895848687ebcbba97eeecf ]
Syzkaller report this:
[ 1213.468581] BUG: unable to handle kernel paging request at fffffbfff83bf338 [ 1213.469530] #PF error: [normal kernel read fault] [ 1213.469530] PGD 237fe4067 P4D 237fe4067 PUD 237e60067 PMD 1c868b067 PTE 0 [ 1213.473514] Oops: 0000 [#1] SMP KASAN PTI [ 1213.473514] CPU: 0 PID: 6321 Comm: syz-executor.0 Tainted: G C 5.1.0-rc3+ #8 [ 1213.473514] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 [ 1213.473514] RIP: 0010:strcmp+0x31/0xa0 [ 1213.473514] Code: 00 00 00 00 fc ff df 55 53 48 83 ec 08 eb 0a 84 db 48 89 ef 74 5a 4c 89 e6 48 89 f8 48 89 fa 48 8d 6f 01 48 c1 e8 03 83 e2 07 <42> 0f b6 04 28 38 d0 7f 04 84 c0 75 50 48 89 f0 48 89 f2 0f b6 5d [ 1213.473514] RSP: 0018:ffff8881f2b7f950 EFLAGS: 00010246 [ 1213.473514] RAX: 1ffffffff83bf338 RBX: ffff8881ea6f7240 RCX: ffffffff825350c6 [ 1213.473514] RDX: 0000000000000000 RSI: ffffffffc1ee19c0 RDI: ffffffffc1df99c0 [ 1213.473514] RBP: ffffffffc1df99c1 R08: 0000000000000001 R09: 0000000000000004 [ 1213.473514] R10: 0000000000000000 R11: ffff8881de353f00 R12: ffff8881ee727900 [ 1213.473514] R13: dffffc0000000000 R14: 0000000000000001 R15: ffffffffc1eeaaf0 [ 1213.473514] FS: 00007fa66fa01700(0000) GS:ffff8881f7200000(0000) knlGS:0000000000000000 [ 1213.473514] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1213.473514] CR2: fffffbfff83bf338 CR3: 00000001ebb9e005 CR4: 00000000007606f0 [ 1213.473514] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1213.473514] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 1213.473514] PKRU: 55555554 [ 1213.473514] Call Trace: [ 1213.473514] led_trigger_register+0x112/0x3f0 [ 1213.473514] led_trigger_register_simple+0x7a/0x110 [ 1213.473514] ? 0xffffffffc1c10000 [ 1213.473514] at76_mod_init+0x77/0x1000 [at76c50x_usb] [ 1213.473514] do_one_initcall+0xbc/0x47d [ 1213.473514] ? perf_trace_initcall_level+0x3a0/0x3a0 [ 1213.473514] ? kasan_unpoison_shadow+0x30/0x40 [ 1213.473514] ? kasan_unpoison_shadow+0x30/0x40 [ 1213.473514] do_init_module+0x1b5/0x547 [ 1213.473514] load_module+0x6405/0x8c10 [ 1213.473514] ? module_frob_arch_sections+0x20/0x20 [ 1213.473514] ? kernel_read_file+0x1e6/0x5d0 [ 1213.473514] ? find_held_lock+0x32/0x1c0 [ 1213.473514] ? cap_capable+0x1ae/0x210 [ 1213.473514] ? __do_sys_finit_module+0x162/0x190 [ 1213.473514] __do_sys_finit_module+0x162/0x190 [ 1213.473514] ? __ia32_sys_init_module+0xa0/0xa0 [ 1213.473514] ? __mutex_unlock_slowpath+0xdc/0x690 [ 1213.473514] ? wait_for_completion+0x370/0x370 [ 1213.473514] ? vfs_write+0x204/0x4a0 [ 1213.473514] ? do_syscall_64+0x18/0x450 [ 1213.473514] do_syscall_64+0x9f/0x450 [ 1213.473514] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 1213.473514] RIP: 0033:0x462e99 [ 1213.473514] Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 [ 1213.473514] RSP: 002b:00007fa66fa00c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 [ 1213.473514] RAX: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99 [ 1213.473514] RDX: 0000000000000000 RSI: 0000000020000300 RDI: 0000000000000003 [ 1213.473514] RBP: 00007fa66fa00c70 R08: 0000000000000000 R09: 0000000000000000 [ 1213.473514] R10: 0000000000000000 R11: 0000000000000246 R12: 00007fa66fa016bc [ 1213.473514] R13: 00000000004bcefa R14: 00000000006f6fb0 R15: 0000000000000004
If usb_register failed, no need to call led_trigger_register_simple.
--- drivers/net/wireless/atmel/at76c50x-usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/atmel/at76c50x-usb.c +2 -2
@@ -2585,8 +2585,8 @@ static int __init at76_mod_init(void)if (result <0 ) printk(KERN_ERR DRIVER_NAME": usb_register failed (status %d)\n" , result); - -led_trigger_register_simple ("at76_usb-tx" , &ledtrig_tx); +else +led_trigger_register_simple ("at76_usb-tx" , &ledtrig_tx);return result; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 41/167 ssb: Fix possible NULL pointer dereference in ssb_host_pcmcia_exit
In reply to Sasha LevinFrom: YueHaibing <[email protected]>
[ Upstream commit b2c01aab9646ed8ffb7c549afe55d5349c482425 ]
Syzkaller report this:
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN PTI CPU: 0 PID: 4492 Comm: syz-executor.0 Not tainted 5.0.0-rc7+ #45 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 RIP: 0010:sysfs_remove_file_ns+0x27/0x70 fs/sysfs/file.c:468 Code: 00 00 00 41 54 55 48 89 fd 53 49 89 d4 48 89 f3 e8 ee 76 9c ff 48 8d 7d 30 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 75 2d 48 89 da 48 b8 00 00 00 00 00 fc ff df 48 8b 6d RSP: 0018:ffff8881e9d9fc00 EFLAGS: 00010206 RAX: dffffc0000000000 RBX: ffffffff900367e0 RCX: ffffffff81a95952 RDX: 0000000000000006 RSI: ffffc90001405000 RDI: 0000000000000030 RBP: 0000000000000000 R08: fffffbfff1fa22ed R09: fffffbfff1fa22ed R10: 0000000000000001 R11: fffffbfff1fa22ec R12: 0000000000000000 R13: ffffffffc1abdac0 R14: 1ffff1103d3b3f8b R15: 0000000000000000 FS: 00007fe409dc1700(0000) GS:ffff8881f1200000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b2d721000 CR3: 00000001e98b6005 CR4: 00000000007606f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: sysfs_remove_file include/linux/sysfs.h:519 [inline] driver_remove_file+0x40/0x50 drivers/base/driver.c:122 pcmcia_remove_newid_file drivers/pcmcia/ds.c:163 [inline] pcmcia_unregister_driver+0x7d/0x2b0 drivers/pcmcia/ds.c:209 ssb_modexit+0xa/0x1b [ssb] __do_sys_delete_module kernel/module.c:1018 [inline] __se_sys_delete_module kernel/module.c:961 [inline] __x64_sys_delete_module+0x3dc/0x5e0 kernel/module.c:961 do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x462e99 Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fe409dc0c58 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0 RAX: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000200000c0 RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007fe409dc16bc R13: 00000000004bccaa R14: 00000000006f6bc8 R15: 00000000ffffffff Modules linked in: ssb(-) 3c59x nvme_core macvlan tap pata_hpt3x3 rt2x00pci null_blk tsc40 pm_notifier_error_inject notifier_error_inject mdio cdc_wdm nf_reject_ipv4 ath9k_common ath9k_hw ath pppox ppp_generic slhc ehci_platform wl12xx wlcore tps6507x_ts ioc4 nf_synproxy_core ide_gd_mod ax25 can_dev iwlwifi can_raw atm tm2_touchkey can_gw can sundance adp5588_keys rt2800mmio rt2800lib rt2x00mmio rt2x00lib eeprom_93cx6 pn533 lru_cache elants_i2c ip_set nfnetlink gameport tipc hampshire nhc_ipv6 nhc_hop nhc_udp nhc_fragment nhc_routing nhc_mobility nhc_dest 6lowpan silead brcmutil nfc mt76_usb mt76 mac80211 iptable_security iptable_raw iptable_mangle iptable_nat nf_nat_ipv4 nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 iptable_filter bpfilter ip6_vti ip_gre sit hsr veth vxcan batman_adv cfg80211 rfkill chnl_net caif nlmon vcan bridge stp llc ip6_gre ip6_tunnel tunnel6 tun joydev mousedev serio_raw ide_pci_generic piix floppy ide_core sch_fq_codel ip_tables x_tables ipv6 [last unloaded: 3c59x] Dumping ftrace buffer: (ftrace buffer empty) ---[ end trace 3913cbf8011e1c05 ]---
In ssb_modinit, it does not fail SSB init when ssb_host_pcmcia_init failed, however in ssb_modexit, ssb_host_pcmcia_exit calls pcmcia_unregister_driver unconditionally, which may tigger a NULL pointer dereference issue as above.
--- drivers/ssb/bridge_pcmcia_80211.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/ssb/bridge_pcmcia_80211.c +7 -2
@@ -113,16 +113,21 @@ static struct pcmcia_driver ssb_host_pcmcia_driver = { .resume = ssb_host_pcmcia_resume, }; +static int pcmcia_init_failed; +/* * These are not module init/exit functions! * The module_pcmcia_driver() helper cannot be used here. */ int ssb_host_pcmcia_init (void ) { -return pcmcia_register_driver (&ssb_host_pcmcia_driver); + pcmcia_init_failed =pcmcia_register_driver (&ssb_host_pcmcia_driver); + +return pcmcia_init_failed; }void ssb_host_pcmcia_exit (void ) { -pcmcia_unregister_driver (&ssb_host_pcmcia_driver); +if (!pcmcia_init_failed) +pcmcia_unregister_driver (&ssb_host_pcmcia_driver); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 42/167 crypto: sun4i-ss - Fix invalid calculation of hash end
In reply to Sasha LevinFrom: Corentin Labbe <[email protected]>
[ Upstream commit f87391558acf816b48f325a493d81d45dec40da0 ]
When nbytes < 4, end is wronlgy set to a negative value which, due to uint, is then interpreted to a large value leading to a deadlock in the following code.
This patch fix this problem.
--- drivers/crypto/sunxi-ss/sun4i-ss-hash.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/crypto/sunxi-ss/sun4i-ss-hash.c +4 -1
@@ -240,7 +240,10 @@ static int sun4i_hash(struct ahash_request *areq) } }else {/* Since we have the flag final, we can go up to modulo 4 */ - end = ((areq->nbytes + op->len) /4 ) *4 - op->len; +if (areq->nbytes <4 ) + end =0 ; +else + end = ((areq->nbytes + op->len) /4 ) *4 - op->len; }/* TODO if SGlen % 4 and !op->len then DMA */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 43/167 bcache: return error immediately in bch_journal_replay()
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit 68d10e6979a3b59e3cd2e90bfcafed79c4cf180a ]
When failure happens inside bch_journal_replay(), calling cache_set_err_on() and handling the failure in async way is not a good idea. Because after bch_journal_replay() returns, registering code will continue to execute following steps, and unregistering code triggered by cache_set_err_on() is running in same time. First it is unnecessary to handle failure and unregister cache set in an async way, second there might be potential race condition to run register and unregister code for same cache set.
So in this patch, if failure happens in bch_journal_replay(), we don't call cache_set_err_on(), and just print out the same error message to kernel message buffer, then return -EIO immediately caller. Then caller can detect such failure and handle it in synchrnozied way.
--- drivers/md/bcache/journal.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/md/bcache/journal.c +6 -3
@@ -323,9 +323,12 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)list_for_each_entry (i, list, list) {BUG_ON (i->pin &&atomic_read (i->pin) !=1 ); -cache_set_err_on (n != i->j.seq, s, -"bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)" , - n, i->j.seq -1 , start, end); +if (n != i->j.seq) { +pr_err ("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)" , + n, i->j.seq -1 , start, end); + ret = -EIO ; + goto err; + } for (k = i->j.start; k < bset_bkey_last(&i->j);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 44/167 bcache: fix failure in journal relplay
In reply to Sasha LevinFrom: Tang Junhui <[email protected]>
[ Upstream commit 631207314d88e9091be02fbdd1fdadb1ae2ed79a ]
journal replay failed with messages:
Sep 10 19:10:43 ceph kernel: bcache: error on
bb379a64-e44e-4812-b91d-a5599871a3b1: bcache: journal entries 2057493-2057567 missing! (replaying 2057493-2076601), disabling caching
The reason is in journal_reclaim(), when discard is enabled, we send discard command and reclaim those journal buckets whose seq is old than the last_seq_now, but before we write a journal with last_seq_now, the machine is restarted, so the journal with the last_seq_now is not written to the journal bucket, and the last_seq_wrote in the newest journal is old than last_seq_now which we expect to be, so when we doing replay, journals from last_seq_wrote to last_seq_now are missing.
It's hard to write a journal immediately after journal_reclaim(), and it harmless if those missed journal are caused by discarding since those journals are already wrote to btree node. So, if miss seqs are started from the beginning journal, we treat it as normal, and only print a message to show the miss journal, and point out it maybe caused by discarding.
Patch v2 add a judgement condition to ignore the missed journal only when discard enabled as Coly suggested.
(Coly Li: rebase the patch with other changes in bch_journal_replay())
--- drivers/md/bcache/journal.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
drivers/md/bcache/journal.c +21 -4
@@ -310,6 +310,18 @@ void bch_journal_mark(struct cache_set *c, struct list_head *list) } } +bool is_discard_enabled (struct cache_set *s) +{ +struct cache *ca; +unsigned int i; + +for_each_cache (ca, s, i) +if (ca->discard) +return true; + +return false; +} +int bch_journal_replay (struct cache_set *s,struct list_head *list) {int ret =0 , keys =0 , entries =0 ;
@@ -324,10 +336,15 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list)BUG_ON (i->pin &&atomic_read (i->pin) !=1 );if (n != i->j.seq) { -pr_err ("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)" , - n, i->j.seq -1 , start, end); - ret = -EIO ; - goto err; +if (n == start &&is_discard_enabled (s)) +pr_info ("bcache: journal entries %llu-%llu may be discarded! (replaying %llu-%llu)" , + n, i->j.seq -1 , start, end); +else { +pr_err ("bcache: journal entries %llu-%llu missing! (replaying %llu-%llu)" , + n, i->j.seq -1 , start, end); + ret = -EIO ; + goto err; + } } for (k = i->j.start;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 45/167 bcache: add failure check to run_cache_set() for journal replay
In reply to Sasha LevinFrom: Coly Li <[email protected]>
[ Upstream commit ce3e4cfb59cb382f8e5ce359238aa580d4ae7778 ]
Currently run_cache_set() has no return value, if there is failure in bch_journal_replay(), the caller of run_cache_set() has no idea about such failure and just continue to execute following code after run_cache_set(). The internal failure is triggered inside bch_journal_replay() and being handled in async way. This behavior is inefficient, while failure handling inside bch_journal_replay(), cache register code is still running to start the cache set. Registering and unregistering code running as same time may introduce some rare race condition, and make the code to be more hard to be understood.
This patch adds return value to run_cache_set(), and returns -EIO if bch_journal_rreplay() fails. Then caller of run_cache_set() may detect such failure and stop registering code flow immedidately inside register_cache_set().
If journal replay fails, run_cache_set() can report error immediately to register_cache_set(). This patch makes the failure handling for bch_journal_replay() be in synchronized way, easier to understand and debug, and avoid poetential race condition for register-and-unregister in same time.
--- drivers/md/bcache/super.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/md/bcache/super.c +12 -5
@@ -1560,7 +1560,7 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)return NULL ; } -static void run_cache_set (struct cache_set *c) +static int run_cache_set (struct cache_set *c) {const char *err ="cannot allocate memory" ;struct cached_dev *dc, *t;
@@ -1652,7 +1652,9 @@ static void run_cache_set(struct cache_set *c)if (j->version <BCACHE_JSET_VERSION_UUID )__uuid_write (c); -bch_journal_replay (c, &journal); + err ="bcache: replay journal failed" ; +if (bch_journal_replay (c, &journal)) + goto err; }else {pr_notice ("invalidating existing data" );
@@ -1720,11 +1722,13 @@ static void run_cache_set(struct cache_set *c)flash_devs_run (c);set_bit (CACHE_SET_RUNNING , &c->flags); -return ; +return 0 ; err:closure_sync (&cl);/* XXX: test this, it's broken */ bch_cache_set_error (c,"%s" , err); + +return -EIO ; }static bool can_attach_cache (struct cache *ca,struct cache_set *c)
@@ -1788,8 +1792,11 @@ static const char *register_cache_set(struct cache *ca) ca->set->cache[ca->sb.nr_this_dev] = ca; c->cache_by_alloc[c->caches_loaded++] = ca; -if (c->caches_loaded == c->sb.nr_in_set) -run_cache_set (c); +if (c->caches_loaded == c->sb.nr_in_set) { + err ="failed to run cache set" ; +if (run_cache_set (c) <0 ) + goto err; + }return NULL ; err:
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 46/167 bcache: avoid clang -Wunintialized warning
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 78d4eb8ad9e1d413449d1b7a060f50b6efa81ebd ]
clang has identified a code path in which it thinks a variable may be unused:
drivers/md/bcache/alloc.c:333:4: error: variable 'bucket' is used uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
fifo_pop(&ca->free_inc, bucket);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/md/bcache/util.h:219:27: note: expanded from macro 'fifo_pop'
#define fifo_pop(fifo, i) fifo_pop_front(fifo, (i))
^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/md/bcache/util.h:189:6: note: expanded from macro 'fifo_pop_front'
if (_r) { \
^~
drivers/md/bcache/alloc.c:343:46: note: uninitialized use occurs here
allocator_wait(ca, bch_allocator_push(ca, bucket));
^~~~~~
drivers/md/bcache/alloc.c:287:7: note: expanded from macro 'allocator_wait'
if (cond) \
^~~~
drivers/md/bcache/alloc.c:333:4: note: remove the 'if' if its condition is always true
fifo_pop(&ca->free_inc, bucket);
^
drivers/md/bcache/util.h:219:27: note: expanded from macro 'fifo_pop'
#define fifo_pop(fifo, i) fifo_pop_front(fifo, (i))
^
drivers/md/bcache/util.h:189:2: note: expanded from macro 'fifo_pop_front'
if (_r) { \
^
drivers/md/bcache/alloc.c:331:15: note: initialize the variable 'bucket' to silence this warning
long bucket;
^This cannot happen in practice because we only enter the loop if there is at least one element in the list.
Slightly rearranging the code makes this clearer to both the reader and the compiler, which avoids the warning.
--- drivers/md/bcache/alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/md/bcache/alloc.c +3 -2
@@ -325,10 +325,11 @@ static int bch_allocator_thread(void *arg)* possibly issue discards to them, then we add the bucket to * the free list: */ -while (!fifo_empty (&ca->free_inc)) { +while (1 ) {long bucket; -fifo_pop (&ca->free_inc, bucket); +if (!fifo_pop (&ca->free_inc, bucket)) +break ;if (ca->discard) {mutex_unlock (&ca->set->bucket_lock);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 47/167 RDMA/cma: Consider scope_id while binding to ipv6 ll address
In reply to Sasha LevinFrom: Parav Pandit <[email protected]>
[ Upstream commit 5d7ed2f27bbd482fd29e6b2e204b1a1ee8a0b268 ]
When two netdev have same link local addresses (such as vlan and non vlan), two rdma cm listen id should be able to bind to following different addresses.
listener-1: addr=lla, scope_id=A, port=X
listener-2: addr=lla, scope_id=B, port=X
However while comparing the addresses only addr and port are considered, due to which 2nd listener fails to listen.
In below example of two listeners, 2nd listener is failing with address in use error.
$ rping -sv -a fe80::268a:7ff:feb3:d113%ens2f1 -p 4545&
$ rping -sv -a fe80::268a:7ff:feb3:d113%ens2f1.200 -p 4545 rdma_bind_addr: Address already in use
To overcome this, consider the scope_ids as well which forms the accurate IPv6 link local address.
--- drivers/infiniband/core/cma.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/infiniband/core/cma.c +19 -6
@@ -1076,18 +1076,31 @@ static inline int cma_any_addr(struct sockaddr *addr)return cma_zero_addr (addr) ||cma_loopback_addr (addr); } -static int cma_addr_cmp (struct sockaddr *src,struct sockaddr *dst) +static int cma_addr_cmp (const struct sockaddr *src,const struct sockaddr *dst) {if (src->sa_family != dst->sa_family)return -1 ;switch (src->sa_family) {case AF_INET : -return ((struct sockaddr_in *) src)->sin_addr.s_addr != - ((struct sockaddr_in *) dst)->sin_addr.s_addr; -case AF_INET6 : -return ipv6_addr_cmp (&((struct sockaddr_in6 *) src)->sin6_addr, - &((struct sockaddr_in6 *) dst)->sin6_addr); +return ((struct sockaddr_in *)src)->sin_addr.s_addr != + ((struct sockaddr_in *)dst)->sin_addr.s_addr; +case AF_INET6 : { +struct sockaddr_in6 *src_addr6 = (struct sockaddr_in6 *)src; +struct sockaddr_in6 *dst_addr6 = (struct sockaddr_in6 *)dst; +bool link_local; + +if (ipv6_addr_cmp (&src_addr6->sin6_addr, + &dst_addr6->sin6_addr)) +return 1 ; + link_local =ipv6_addr_type (&dst_addr6->sin6_addr) & +IPV6_ADDR_LINKLOCAL ; +/* Link local must match their scope_ids */ +return link_local ? (src_addr6->sin6_scope_id != + dst_addr6->sin6_scope_id) : +0 ; + } +default :return ib_addr_cmp (&((struct sockaddr_ib *) src)->sib_addr, &((struct sockaddr_ib *) dst)->sib_addr);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 48/167 vfio-ccw: Do not call flush_workqueue while holding the spinlock
In reply to Sasha LevinFrom: Farhan Ali <[email protected]>
[ Upstream commit cea5dde42a83b5f0a039da672f8686455936b8d8 ]
Currently we call flush_workqueue while holding the subchannel spinlock. But flush_workqueue function can go to sleep, so do not call the function while holding the spinlock.
Fixes the following bug:
[ 285.203430] BUG: scheduling while atomic: bash/14193/0x00000002 [ 285.203434] INFO: lockdep is turned off. .... [ 285.203485] Preemption disabled at: [ 285.203488] [<000003ff80243e5c>] vfio_ccw_sch_quiesce+0xbc/0x120 [vfio_ccw] [ 285.203496] CPU: 7 PID: 14193 Comm: bash Tainted: G W .... [ 285.203504] Call Trace: [ 285.203510] ([<0000000000113772>] show_stack+0x82/0xd0) [ 285.203514] [<0000000000b7a102>] dump_stack+0x92/0xd0 [ 285.203518] [<000000000017b8be>] __schedule_bug+0xde/0xf8 [ 285.203524] [<0000000000b95b5a>] __schedule+0x7a/0xc38 [ 285.203528] [<0000000000b9678a>] schedule+0x72/0xb0 [ 285.203533] [<0000000000b9bfbc>] schedule_timeout+0x34/0x528 [ 285.203538] [<0000000000b97608>] wait_for_common+0x118/0x1b0 [ 285.203544] [<0000000000166d6a>] flush_workqueue+0x182/0x548 [ 285.203550] [<000003ff80243e6e>] vfio_ccw_sch_quiesce+0xce/0x120 [vfio_ccw] [ 285.203556] [<000003ff80245278>] vfio_ccw_mdev_reset+0x38/0x70 [vfio_ccw] [ 285.203562] [<000003ff802458b0>] vfio_ccw_mdev_remove+0x40/0x78 [vfio_ccw] [ 285.203567] [<000003ff801a499c>] mdev_device_remove_ops+0x3c/0x80 [mdev] [ 285.203573] [<000003ff801a4d5c>] mdev_device_remove+0xc4/0x130 [mdev] [ 285.203578] [<000003ff801a5074>] remove_store+0x6c/0xa8 [mdev] [ 285.203582] [<000000000046f494>] kernfs_fop_write+0x14c/0x1f8 [ 285.203588] [<00000000003c1530>] __vfs_write+0x38/0x1a8 [ 285.203593] [<00000000003c187c>] vfs_write+0xb4/0x198 [ 285.203597] [<00000000003c1af2>] ksys_write+0x5a/0xb0 [ 285.203601] [<0000000000b9e270>] system_call+0xdc/0x2d8
Message-Id: <626bab8bb2958ae132452e1ddaf1b20882ad5a9d.1554756534.git.alifm@linux.ibm.com>
--- drivers/s390/cio/vfio_ccw_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/vfio_ccw_drv.c +1 -1
@@ -52,9 +52,9 @@ int vfio_ccw_sch_quiesce(struct subchannel *sch)wait_for_completion_timeout (&completion,3 *HZ ); -spin_lock_irq (sch->lock); private->completion =NULL ;flush_workqueue (vfio_ccw_work_q); +spin_lock_irq (sch->lock); ret =cio_cancel_halt_clear (sch, &iretry); };
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 49/167 vfio-ccw: Release any channel program when releasing/removing vfio-ccw mdev
In reply to Sasha LevinFrom: Farhan Ali <[email protected]>
[ Upstream commit b49bdc8602b7c9c7a977758bee4125683f73e59f ]
When releasing the vfio-ccw mdev, we currently do not release any existing channel program and its pinned pages. This can lead to the following warning:
[1038876.561565] WARNING: CPU: 2 PID: 144727 at drivers/vfio/vfio_iommu_type1.c:1494 vfio_sanity_check_pfn_list+0x40/0x70 [vfio_iommu_type1]
....
1038876.561921] Call Trace:
[1038876.561935] ([<00000009897fb870>] 0x9897fb870)
[1038876.561949] [<000003ff8013bf62>] vfio_iommu_type1_detach_group+0xda/0x2f0 [vfio_iommu_type1]
[1038876.561965] [<000003ff8007b634>] __vfio_group_unset_container+0x64/0x190 [vfio]
[1038876.561978] [<000003ff8007b87e>] vfio_group_put_external_user+0x26/0x38 [vfio]
[1038876.562024] [<000003ff806fc608>] kvm_vfio_group_put_external_user+0x40/0x60 [kvm]
[1038876.562045] [<000003ff806fcb9e>] kvm_vfio_destroy+0x5e/0xd0 [kvm]
[1038876.562065] [<000003ff806f63fc>] kvm_put_kvm+0x2a4/0x3d0 [kvm]
[1038876.562083] [<000003ff806f655e>] kvm_vm_release+0x36/0x48 [kvm]
[1038876.562098] [<00000000003c2dc4>] __fput+0x144/0x228
[1038876.562113] [<000000000016ee82>] task_work_run+0x8a/0xd8
[1038876.562125] [<000000000014c7a8>] do_exit+0x5d8/0xd90
[1038876.562140] [<000000000014d084>] do_group_exit+0xc4/0xc8
[1038876.562155] [<000000000015c046>] get_signal+0x9ae/0xa68
[1038876.562169] [<0000000000108d66>] do_signal+0x66/0x768
[1038876.562185] [<0000000000b9e37e>] system_call+0x1ea/0x2d8
[1038876.562195] 2 locks held by qemu-system-s39/144727:
[1038876.562205] #0: 00000000537abaf9 (&container->group_lock){++++}, at: __vfio_group_unset_container+0x3c/0x190 [vfio]
[1038876.562230] #1: 00000000670008b5 (&iommu->lock){+.+.}, at: vfio_iommu_type1_detach_group+0x36/0x2f0 [vfio_iommu_type1]
[1038876.562250] Last Breaking-Event-Address:
[1038876.562262] [<000003ff8013aa24>] vfio_sanity_check_pfn_list+0x3c/0x70 [vfio_iommu_type1]
[1038876.562272] irq event stamp: 4236481
[1038876.562287] hardirqs last enabled at (4236489): [<00000000001cee7a>] console_unlock+0x6d2/0x740
[1038876.562299] hardirqs last disabled at (4236496): [<00000000001ce87e>] console_unlock+0xd6/0x740
[1038876.562311] softirqs last enabled at (4234162): [<0000000000b9fa1e>] __do_softirq+0x556/0x598
[1038876.562325] softirqs last disabled at (4234153): [<000000000014e4cc>] irq_exit+0xac/0x108
[1038876.562337] ---[ end trace 6c96d467b1c3ca06 ]---Similarly we do not free the channel program when we are removing the vfio-ccw device. Let's fix this by resetting the device and freeing the channel program and pinned pages in the release path. For the remove path we can just quiesce the device, since in the remove path the mediated device is going away for good and so we don't need to do a full reset.
Message-Id: <ae9f20dc8873f2027f7b3c5d2aaa0bdfe06850b8.1554756534.git.alifm@linux.ibm.com>
--- drivers/s390/cio/vfio_ccw_ops.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/s390/cio/vfio_ccw_ops.c +10 -1
@@ -130,11 +130,12 @@ static int vfio_ccw_mdev_remove(struct mdev_device *mdev)if ((private->state !=VFIO_CCW_STATE_NOT_OPER ) && (private->state !=VFIO_CCW_STATE_STANDBY )) { -if (!vfio_ccw_mdev_reset (mdev)) +if (!vfio_ccw_sch_quiesce (private->sch)) private->state =VFIO_CCW_STATE_STANDBY ;/* The state will be NOT_OPER on error. */ } +cp_free (&private->cp); private->mdev =NULL ;atomic_inc (&private->avail);
@@ -158,6 +159,14 @@ static void vfio_ccw_mdev_release(struct mdev_device *mdev)struct vfio_ccw_private *private =dev_get_drvdata (mdev_parent_dev (mdev)); +if ((private->state !=VFIO_CCW_STATE_NOT_OPER ) && + (private->state !=VFIO_CCW_STATE_STANDBY )) { +if (!vfio_ccw_mdev_reset (mdev)) + private->state =VFIO_CCW_STATE_STANDBY ; +/* The state will be NOT_OPER on error. */ + } + +cp_free (&private->cp);vfio_unregister_notifier (mdev_dev (mdev),VFIO_IOMMU_NOTIFY , &private->nb); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 50/167 x86/build: Move _etext to actual end of .text
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit 392bef709659abea614abfe53cf228e7a59876a4 ]
When building x86 with Clang LTO and CFI, CFI jump regions are automatically added to the end of the .text section late in linking. As a result, the _etext position was being labelled before the appended jump regions, causing confusion about where the boundaries of the executable region actually are in the running kernel, and broke at least the fault injection code. This moves the _etext mark to outside (and immediately after) the .text area, as it already the case on other architectures (e.g. arm64, arm).
--- arch/x86/kernel/vmlinux.lds.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/vmlinux.lds.S +3 -3
@@ -131,11 +131,11 @@ SECTIONS *(.text.__x86.indirect_thunk) __indirect_thunk_end = .; #endif - - /* End of text section */ - _etext = .; } :text = 0x9090 + /* End of text section */ + _etext = .; + NOTES :text :note EXCEPTION_TABLE(16) :text = 0x9090
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 51/167 smpboot: Place the __percpu annotation correctly
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit d4645d30b50d1691c26ff0f8fa4e718b08f8d3bb ]
The test robot reported a wrong assignment of a per-CPU variable which it detected by using sparse and sent a report. The assignment itself is correct. The annotation for sparse was wrong and hence the report. The first pointer is a "normal" pointer and points to the per-CPU memory area. That means that the __percpu annotation has to be moved.
Move the __percpu annotation to pointer which points to the per-CPU area. This change affects only the sparse tool (and is ignored by the compiler).
--- include/linux/smpboot.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/smpboot.h +1 -1
@@ -31,7 +31,7 @@ struct smpboot_thread_data;* @thread_comm: The base name of the thread */ struct smp_hotplug_thread { -struct task_struct __percpu **store; +struct task_struct *__percpu *store;struct list_head list;int (*thread_should_run)(unsigned int cpu);void (*thread_fn)(unsigned int cpu);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 52/167 x86/mm: Remove in_nmi() warning from 64-bit implementation of vmalloc_fault()
In reply to Sasha LevinFrom: Jiri Kosina <[email protected]>
[ Upstream commit a65c88e16f32aa9ef2e8caa68ea5c29bd5eb0ff0 ]
In-NMI warnings have been added to vmalloc_fault() via:
ebc8827f75 ("x86: Barf when vmalloc and kmemcheck faults happen in NMI")
back in the time when our NMI entry code could not cope with nested NMIs.
These days, it's perfectly fine to take a fault in NMI context and we don't have to care about the fact that IRET from the fault handler might cause NMI nesting.
This warning has already been removed from 32-bit implementation of vmalloc_fault() in:
6863ea0cda8 ("x86/mm: Remove in_nmi() warning from vmalloc_fault()")
but the 64-bit version was omitted.
Remove the bogus warning also from 64-bit implementation of vmalloc_fault().
--- arch/x86/mm/fault.c | 2 -- 1 file changed, 2 deletions(-)
arch/x86/mm/fault.c +0 -2
@@ -426,8 +426,6 @@ static noinline int vmalloc_fault(unsigned long address)if (!(address >=VMALLOC_START && address <VMALLOC_END ))return -1 ; -WARN_ON_ONCE (in_nmi ()); -/* * Copy kernel mappings over when needed. This can also * happen within a race in page table update. In the later
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 53/167 mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 29da93fea3ea39ab9b12270cc6be1b70ef201c9e ]
Randy reported objtool triggered on his (GCC-7.4) build:
lib/strncpy_from_user.o: warning: objtool: strncpy_from_user()+0x315: call to __ubsan_handle_add_overflow() with UACCESS enabled lib/strnlen_user.o: warning: objtool: strnlen_user()+0x337: call to __ubsan_handle_sub_overflow() with UACCESS enabled
This is due to UBSAN generating signed-overflow-UB warnings where it should not. Prior to GCC-8 UBSAN ignored -fwrapv (which the kernel uses through -fno-strict-overflow).
Make the functions use 'unsigned long' throughout.
--- lib/strncpy_from_user.c | 5 +++-- lib/strnlen_user.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-)
lib/strncpy_from_user.c +3 -2
@@ -23,10 +23,11 @@* hit it), 'max' is the address space maximum (and we return * -EFAULT if we hit it). */ -static inline long do_strncpy_from_user (char *dst,const char __user *src,long count,unsigned long max) +static inline long do_strncpy_from_user (char *dst,const char __user *src, +unsigned long count,unsigned long max) {const struct word_at_a_time constants =WORD_AT_A_TIME_CONSTANTS ; -long res =0 ; +unsigned long res =0 ;/* * Truncate 'max' to the user-specified limit, so that
lib/strnlen_user.c +2 -2
@@ -28,7 +28,7 @@static inline long do_strnlen_user (const char __user *src,unsigned long count,unsigned long max) {const struct word_at_a_time constants =WORD_AT_A_TIME_CONSTANTS ; -long align, res =0 ; +unsigned long align, res =0 ;unsigned long c;/*
@@ -42,7 +42,7 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count,* Do everything aligned. But that means that we * need to also expand the maximum.. */ - align = (sizeof (long ) -1 ) & (unsigned long )src; + align = (sizeof (unsigned long ) -1 ) & (unsigned long )src; src -= align; max += align;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 54/167 HID: logitech-hidpp: use RAP instead of FAP to get the protocol version
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 096377525cdb8251e4656085efc988bdf733fb4c ]
According to the logitech_hidpp_2.0_specification_draft_2012-06-04.pdf doc:
https://lekensteyn.nl/files/logitech/logitech_hidpp_2.0_specification_draft_2012-06-04.pdf
We should use a register-access-protocol request using the short input / output report ids. This is necessary because 27MHz HID++ receivers have a max-packetsize on their HIP++ endpoint of 8, so they cannot support long reports. Using a feature-access-protocol request (which is always long or very-long) with these will cause a timeout error, followed by the hidpp driver treating the device as not being HID++ capable.
This commit fixes this by switching to using a rap request to get the protocol version.
Besides being tested with a (046d:c517) 27MHz receiver with various 27MHz keyboards and mice, this has also been tested to not cause regressions on a non-unifying dual-HID++ nano receiver (046d:c534) with k270 and m185 HID++-2.0 devices connected and on a unifying/dj receiver (046d:c52b) with a HID++-2.0 Logitech Rechargeable Touchpad T650.
--- drivers/hid/hid-logitech-hidpp.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/hid/hid-logitech-hidpp.c +13 -4
@@ -725,13 +725,16 @@ static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature,static int hidpp_root_get_protocol_version (struct hidpp_device *hidpp) { +const u8 ping_byte =0x5a ; +u8 ping_data[3 ] = {0 ,0 , ping_byte };struct hidpp_report response;int ret; - ret =hidpp_send_fap_command_sync (hidpp, + ret =hidpp_send_rap_command_sync (hidpp, +REPORT_ID_HIDPP_SHORT ,HIDPP_PAGE_ROOT_IDX ,CMD_ROOT_GET_PROTOCOL_VERSION , -NULL ,0 , &response); + ping_data,sizeof (ping_data), &response);if (ret ==HIDPP_ERROR_INVALID_SUBID ) { hidpp->protocol_major =1 ;
@@ -751,8 +754,14 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)if (ret)return ret; - hidpp->protocol_major = response.fap.params[0 ]; - hidpp->protocol_minor = response.fap.params[1 ]; +if (response.rap.params[2 ] != ping_byte) { +hid_err (hidpp->hid_dev,"%s: ping mismatch 0x%02x != 0x%02x\n" , + __func__, response.rap.params[2 ], ping_byte); +return -EPROTO ; + } + + hidpp->protocol_major = response.rap.params[0 ]; + hidpp->protocol_minor = response.rap.params[1 ];return ret; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 55/167 pinctrl: pistachio: fix leaked of_node references
In reply to Sasha LevinFrom: Wen Yang <[email protected]>
[ Upstream commit 44a4455ac2c6b0981eace683a2b6eccf47689022 ]
The call to of_get_child_by_name returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage.
Detected by coccinelle with the following warnings:
./drivers/pinctrl/pinctrl-pistachio.c:1422:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1360, but without a corresponding object release within this function.
--- drivers/pinctrl/pinctrl-pistachio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/pinctrl-pistachio.c +2 -0
@@ -1368,6 +1368,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)if (!of_find_property (child,"gpio-controller" ,NULL )) {dev_err (pctl->dev,"No gpio-controller property for bank %u\n" , i); +of_node_put (child); ret = -ENODEV ; goto err; }
@@ -1375,6 +1376,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl) irq =irq_of_parse_and_map (child,0 );if (irq <0 ) {dev_err (pctl->dev,"No IRQ for bank %u: %d\n" , i, irq); +of_node_put (child); ret = irq; goto err; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 56/167 pinctrl: samsung: fix leaked of_node references
In reply to Sasha LevinFrom: Wen Yang <[email protected]>
[ Upstream commit 44b9f86cd41db6c522effa5aec251d664a52fbc0 ]
The call to of_find_compatible_node returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage.
Detected by coccinelle with the following warnings:
./drivers/pinctrl/samsung/pinctrl-exynos-arm.c:76:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function. ./drivers/pinctrl/samsung/pinctrl-exynos-arm.c:82:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 66, but without a corresponding object release within this function.
--- drivers/pinctrl/samsung/pinctrl-exynos-arm.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/samsung/pinctrl-exynos-arm.c +1 -0
@@ -76,6 +76,7 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata, } clk_base =of_iomap (np,0 ); +of_node_put (np);if (!clk_base) {pr_err ("%s: failed to map clock registers\n" , __func__);return ERR_PTR (-EINVAL );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 57/167 clk: rockchip: undo several noc and special clocks as critical on rk3288
In reply to Sasha LevinFrom: Douglas Anderson <[email protected]>
[ Upstream commit f4033db5b84ebe4b32c25ba2ed65ab20b628996a ]
This is mostly a revert of commit 55bb6a633c33 ("clk: rockchip: mark noc and some special clk as critical on rk3288") except that we're keeping "pmu_hclk_otg0" as critical still.
NOTE: turning these clocks off doesn't seem to do a whole lot in terms of power savings (checking the power on the logic rail). It appears to save maybe 1-2mW. ...but still it seems like we should turn the clocks off if they aren't needed.
About "pmu_hclk_otg0" (the one clock from the original commit we're still keeping critical) from an email thread:
Quoted 12 lines
pmu ahb clock
Function: Clock to pmu module when hibernation and/or ADP is enabled. Must be greater than or equal to 30 MHz.
If the SOC design does not support hibernation/ADP function, only have
hclk_otg, this clk can be switched according to the usage of otg. If the SOC design support hibernation/ADP, has two clocks,hclk_otgandpmu_hclk_otg0.Hclk_otgbelongs to the closed part of otg logic, which can be switched according to the use of otg.
Quoted 4 lines
pmu_hclk_otg0belongs to the always on part.As for whether
pmu_hclk_otg0can be turned off when otg is not in use, we have not tested. IC suggest makepmu_hclk_otg0always on.
For the rest of the clocks:
atclk: No documentation about this clock other than that it goes to the CPU. CPU functions fine without it on. Maybe needed for JTAG?
jtag: Presumably this clock is only needed if you're debugging with JTAG. It doesn't seem like it makes sense to waste power for every rk3288 user. In any case to do JTAG you'd need private patches to adjust the pinctrl the mux the JTAG out anyway.
pclk_dbg, pclk_core_niu: On veyron Chromebooks we turn these two clocks on only during kernel panics in order to access some coresight registers. Since nothing in the upstream kernel does this we should be able to leave them off safely. Maybe also needed for JTAG?
hsicphy12m_xin12m: There is no indication of why this clock would need to be turned on for boards that don't use HSIC.
pclk_ddrupctl[0-1], pclk_publ0[0-1]: On veyron Chromebooks we turn these 4 clocks on only when doing DDR transitions and they are off otherwise. I see no reason why they'd need to be on in the upstream kernel which doesn't support DDRFreq.
--- drivers/clk/rockchip/clk-rk3288.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/clk/rockchip/clk-rk3288.c +4 -9
@@ -292,13 +292,13 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {COMPOSITE_NOMUX (0 ,"aclk_core_mp" ,"armclk" ,CLK_IGNORE_UNUSED ,RK3288_CLKSEL_CON (0 ),4 ,4 ,DFLAGS |CLK_DIVIDER_READ_ONLY ,RK3288_CLKGATE_CON (12 ),6 ,GFLAGS ), -COMPOSITE_NOMUX (0 ,"atclk" ,"armclk" ,CLK_IGNORE_UNUSED , +COMPOSITE_NOMUX (0 ,"atclk" ,"armclk" ,0 ,RK3288_CLKSEL_CON (37 ),4 ,5 ,DFLAGS |CLK_DIVIDER_READ_ONLY ,RK3288_CLKGATE_CON (12 ),7 ,GFLAGS ),COMPOSITE_NOMUX (0 ,"pclk_dbg_pre" ,"armclk" ,CLK_IGNORE_UNUSED ,RK3288_CLKSEL_CON (37 ),9 ,5 ,DFLAGS |CLK_DIVIDER_READ_ONLY ,RK3288_CLKGATE_CON (12 ),8 ,GFLAGS ), -GATE (0 ,"pclk_dbg" ,"pclk_dbg_pre" ,CLK_IGNORE_UNUSED , +GATE (0 ,"pclk_dbg" ,"pclk_dbg_pre" ,0 ,RK3288_CLKGATE_CON (12 ),9 ,GFLAGS ),GATE (0 ,"cs_dbg" ,"pclk_dbg_pre" ,CLK_IGNORE_UNUSED , RK3288_CLKGATE_CON(12), 10, GFLAGS),
@@ -626,7 +626,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {INVERTER (SCLK_HSADC ,"sclk_hsadc" ,"sclk_hsadc_out" ,RK3288_CLKSEL_CON (22 ),7 ,IFLAGS ), -GATE (0 ,"jtag" ,"ext_jtag" ,CLK_IGNORE_UNUSED , +GATE (0 ,"jtag" ,"ext_jtag" ,0 ,RK3288_CLKGATE_CON (4 ),14 ,GFLAGS ), COMPOSITE_NODIV(SCLK_USBPHY480M_SRC, "usbphy480m_src", mux_usbphy480m_p, 0,
@@ -635,7 +635,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {COMPOSITE_NODIV (SCLK_HSICPHY480M ,"sclk_hsicphy480m" , mux_hsicphy480m_p,0 ,RK3288_CLKSEL_CON (29 ),0 ,2 ,MFLAGS ,RK3288_CLKGATE_CON (3 ),6 ,GFLAGS ), -GATE (0 ,"hsicphy12m_xin12m" ,"xin12m" ,CLK_IGNORE_UNUSED , +GATE (0 ,"hsicphy12m_xin12m" ,"xin12m" ,0 ,RK3288_CLKGATE_CON (13 ),9 ,GFLAGS ),DIV (0 ,"hsicphy12m_usbphy" ,"sclk_hsicphy480m" ,0 , RK3288_CLKSEL_CON(11), 8, 6, DFLAGS),
@@ -816,11 +816,6 @@ static const char *const rk3288_critical_clocks[] __initconst = {"pclk_alive_niu" ,"pclk_pd_pmu" ,"pclk_pmu_niu" , -"pclk_core_niu" , -"pclk_ddrupctl0" , -"pclk_publ0" , -"pclk_ddrupctl1" , -"pclk_publ1" , "pmu_hclk_otg0", };
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 58/167 dmaengine: at_xdmac: remove BUG_ON macro in tasklet
In reply to Sasha LevinFrom: Nicolas Ferre <[email protected]>
[ Upstream commit e2c114c06da2d9ffad5b16690abf008d6696f689 ]
Even if this case shouldn't happen when controller is properly programmed, it's still better to avoid dumping a kernel Oops for this.
As the sequence may happen only for debugging purposes, log the error and just finish the tasklet call.
--- drivers/dma/at_xdmac.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/dma/at_xdmac.c +5 -1
@@ -1606,7 +1606,11 @@ static void at_xdmac_tasklet(unsigned long data) struct at_xdmac_desc, xfer_node);dev_vdbg (chan2dev (&atchan->chan),"%s: desc 0x%p\n" , __func__, desc); -BUG_ON (!desc->active_xfer); +if (!desc->active_xfer) { +dev_err (chan2dev (&atchan->chan),"Xfer not active: exiting" ); +spin_unlock_bh (&atchan->lock); +return ; + } txd = &desc->tx_dma_desc;
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 59/167 media: coda: clear error return value before picture run
In reply to Sasha LevinFrom: Philipp Zabel <[email protected]>
[ Upstream commit bbeefa7357a648afe70e7183914c87c3878d528d ]
The error return value is not written by some firmware codecs, such as MPEG-2 decode on CodaHx4. Clear the error return value before starting the picture run to avoid misinterpreting unrelated values returned by sequence initialization as error return value.
--- drivers/media/platform/coda/coda-bit.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/coda/coda-bit.c +3 -0
@@ -1948,6 +1948,9 @@ static int coda_prepare_decode(struct coda_ctx *ctx)/* Clear decode success flag */ coda_write (dev,0 ,CODA_RET_DEC_PIC_SUCCESS ); +/* Clear error return value */ +coda_write (dev,0 ,CODA_RET_DEC_PIC_ERR_MB ); +trace_coda_dec_pic_run (ctx, meta);coda_command_async (ctx,CODA_COMMAND_PIC_RUN );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 60/167 media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper
In reply to Sasha LevinFrom: Janusz Krzysztofik <[email protected]>
[ Upstream commit ccdd85d518d8b9320ace1d87271f0ba2175f21fa ]
In preparation for adding asynchronous subdevice support to the driver, don't acquire v4l2_clk from the driver .probe() callback as that may fail if the clock is provided by a bridge driver which may be not yet initialized. Move the v4l2_clk_get() to ov6650_video_probe() helper which is going to be converted to v4l2_subdev_internal_ops.registered() callback, executed only when the bridge driver is ready.
--- drivers/media/i2c/ov6650.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
drivers/media/i2c/ov6650.c +14 -11
@@ -822,9 +822,16 @@ static int ov6650_video_probe(struct i2c_client *client)u8 pidh, pidl, midh, midl;int ret; + priv->clk =v4l2_clk_get (&client->dev,NULL ); +if (IS_ERR (priv->clk)) { + ret =PTR_ERR (priv->clk); +dev_err (&client->dev,"v4l2_clk request err: %d\n" , ret); +return ret; + } + ret =ov6650_s_power (&priv->subdev,1 );if (ret <0 ) -return ret; + goto eclkput;/* * check and show product ID and manufacturer ID
@@ -859,6 +866,11 @@ static int ov6650_video_probe(struct i2c_client *client) done:ov6650_s_power (&priv->subdev,0 ); +if (!ret) +return 0 ; +eclkput: +v4l2_clk_put (priv->clk); +return ret; }
@@ -1004,18 +1016,9 @@ static int ov6650_probe(struct i2c_client *client, priv->code =MEDIA_BUS_FMT_YUYV8_2X8 ; priv->colorspace =V4L2_COLORSPACE_JPEG ; - priv->clk =v4l2_clk_get (&client->dev,NULL ); -if (IS_ERR (priv->clk)) { - ret =PTR_ERR (priv->clk); - goto eclkget; - } - ret =ov6650_video_probe (client); -if (ret) { -v4l2_clk_put (priv->clk); -eclkget: +if (ret)v4l2_ctrl_handler_free (&priv->hdl); - }return ret; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 61/167 media: au0828: stop video streaming only when last user stops
In reply to Sasha LevinFrom: Hans Verkuil <[email protected]>
[ Upstream commit f604f0f5afb88045944567f604409951b5eb6af8 ]
If the application was streaming from both videoX and vbiX, and streaming from videoX was stopped, then the vbi streaming also stopped.
The cause being that stop_streaming for video stopped the subdevs as well, instead of only doing that if dev->streaming_users reached 0.
au0828_stop_vbi_streaming was also wrong since it didn't stop the subdevs at all when dev->streaming_users reached 0.
--- drivers/media/usb/au0828/au0828-video.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/media/usb/au0828/au0828-video.c +8 -5
@@ -839,9 +839,9 @@ int au0828_start_analog_streaming(struct vb2_queue *vq, unsigned int count)return rc; } +v4l2_device_call_all (&dev->v4l2_dev,0 , video, s_stream,1 ); +if (vq->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE ) { -v4l2_device_call_all (&dev->v4l2_dev,0 , video, - s_stream,1 ); dev->vid_timeout_running =1 ;mod_timer (&dev->vid_timeout, jiffies + (HZ /10 )); }else if (vq->type ==V4L2_BUF_TYPE_VBI_CAPTURE ) {
@@ -861,10 +861,11 @@ static void au0828_stop_streaming(struct vb2_queue *vq)dprintk (1 ,"au0828_stop_streaming called %d\n" , dev->streaming_users); -if (dev->streaming_users-- ==1 ) +if (dev->streaming_users-- ==1 ) {au0828_uninit_isoc (dev); +v4l2_device_call_all (&dev->v4l2_dev,0 , video, s_stream,0 ); + } -v4l2_device_call_all (&dev->v4l2_dev,0 , video, s_stream,0 ); dev->vid_timeout_running =0 ;del_timer_sync (&dev->vid_timeout);
@@ -893,8 +894,10 @@ void au0828_stop_vbi_streaming(struct vb2_queue *vq)dprintk (1 ,"au0828_stop_vbi_streaming called %d\n" , dev->streaming_users); -if (dev->streaming_users-- ==1 ) +if (dev->streaming_users-- ==1 ) {au0828_uninit_isoc (dev); +v4l2_device_call_all (&dev->v4l2_dev,0 , video, s_stream,0 ); + }spin_lock_irqsave (&dev->slock, flags);if (dev->isoc_ctl.vbi_buf !=NULL ) {
Signature · 1 line
2.20.1