• Lu Baolu's avatar
    usb: xhci: dbc: Fix lockdep warning · a098dc8b
    Lu Baolu authored
    The xHCI DbC implementation might enter a deadlock situation because
    there is no sufficient protection against the shared data between
    process and softirq contexts. This can lead to the following lockdep
    warnings. This patch changes to use spin_{,un}lock_irq{save,restore}
    to avoid potential deadlock.
    
    [ 528.248084] ================================
    [ 528.252914] WARNING: inconsistent lock state
    [ 528.257756] 4.15.0-rc1+ #1630 Not tainted
    [ 528.262305] --------------------------------
    [ 528.267145] inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
    [ 528.273953] ksoftirqd/1/17 [HC0[0]:SC1[1]:HE0:SE0] takes:
    [ 528.280075] (&(&port->port_lock)->rlock){+.?.}, at: [<ffffffff815396a8>] dbc_rx_push+0x38/0x1c0
    [ 528.290043] {SOFTIRQ-ON-W} state was registered at:
    [ 528.295570] _raw_spin_lock+0x2f/0x40
    [ 528.299818] dbc_write_complete+0x27/0xa0
    [ 528.304458] xhci_dbc_giveback+0xd1/0x200
    [ 528.309098] xhci_dbc_flush_endpoint_requests+0x50/0x70
    [ 528.315116] xhci_dbc_handle_events+0x696/0x7b0
    [ 528.320349] process_one_work+0x1ee/0x6e0
    [ 528.324988] worker_thread+0x4a/0x430
    [ 528.329236] kthread+0x13e/0x170
    [ 528.332992] ret_from_fork+0x24/0x30
    [ 528.337141] irq event stamp: 2861
    [ 528.340897] hardirqs last enabled at (2860): [<ffffffff810674ea>] tasklet_action+0x6a/0x250
    [ 528.350460] hardirqs last disabled at (2861): [<ffffffff817dc1ef>] _raw_spin_lock_irq+0xf/0x40
    [ 528.360219] softirqs last enabled at (2852): [<ffffffff817e0e8c>] __do_softirq+0x3dc/0x4f9
    [ 528.369683] softirqs last disabled at (2857): [<ffffffff8106805b>] run_ksoftirqd+0x1b/0x60
    [ 528.379048]
    [ 528.379048] other info that might help us debug this:
    [ 528.386443] Possible unsafe locking scenario:
    [ 528.386443]
    [ 528.393150] CPU0
    [ 528.395917] ----
    [ 528.398687] lock(&(&port->port_lock)->rlock);
    [ 528.403821] <Interrupt>
    [ 528.406786] lock(&(&port->port_lock)->rlock);
    [ 528.412116]
    [ 528.412116] *** DEADLOCK ***
    [ 528.412116]
    [ 528.418825] no locks held by ksoftirqd/1/17.
    [ 528.423662]
    [ 528.423662] stack backtrace:
    [ 528.428598] CPU: 1 PID: 17 Comm: ksoftirqd/1 Not tainted 4.15.0-rc1+ #1630
    [ 528.436387] Call Trace:
    [ 528.439158] dump_stack+0x5e/0x8e
    [ 528.442914] print_usage_bug+0x1fc/0x220
    [ 528.447357] mark_lock+0x4db/0x5a0
    [ 528.451210] __lock_acquire+0x726/0x1130
    [ 528.455655] ? __lock_acquire+0x557/0x1130
    [ 528.460296] lock_acquire+0xa2/0x200
    [ 528.464347] ? dbc_rx_push+0x38/0x1c0
    [ 528.468496] _raw_spin_lock_irq+0x35/0x40
    [ 528.473038] ? dbc_rx_push+0x38/0x1c0
    [ 528.477186] dbc_rx_push+0x38/0x1c0
    [ 528.481139] tasklet_action+0x1d2/0x250
    [ 528.485483] __do_softirq+0x1dc/0x4f9
    [ 528.489630] run_ksoftirqd+0x1b/0x60
    [ 528.493682] smpboot_thread_fn+0x179/0x270
    [ 528.498324] kthread+0x13e/0x170
    [ 528.501981] ? sort_range+0x20/0x20
    [ 528.505933] ? kthread_delayed_work_timer_fn+0x80/0x80
    [ 528.511755] ret_from_fork+0x24/0x30
    
    Fixes: dfba2174 ("usb: xhci: Add DbC support in xHCI driver")
    Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    a098dc8b
xhci-dbgcap.c 22.4 KB