Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit b713a755 authored by Can Guo's avatar Can Guo
Browse files

scsi: ufs: fix a race condition between err handler and clock gate work



During clock gating, if hibern8 enter fails, driver shall schedule error
handler work and wait on its completion. In error handler, if the state of
clock is not CLKS_ON, which is the case here, it shall ungate the clock and
wait on completion. Thus it would run into below race condition. It is not
necessary to ungate clock for this situation, because the clocks are still
active before hibern8 enter completes. This change fixes this race
condition by setting eh_in_progress flags before start err_handler so that
when it tries to ungate clocks, ufshcd_hold only increases the clock usage
counter without actually flushing the gate work.

Process: kworker/u16:11, cpu: 0 pid: 542 start: 0xffffffdce1f05580
    Task name: kworker/u16:11 pid: 542 cpu: 0
    state: 0x2 exit_state: 0x0 stack base: 0xffffff801ac18000
    Stack:
    [<ffffff8ac5a85d2c>] __switch_to+0xb8
    [<ffffff8ac6a7e654>] __schedule+0x690
    [<ffffff8ac6a7e8cc>] schedule+0x70
    [<ffffff8ac6a82218>] schedule_timeout+0x44
    [<ffffff8ac6a7fc5c>] do_wait_for_common+0xf0
    [<ffffff8ac6a7f970>] wait_for_common+0x58
    [<ffffff8ac6a7f90c>] wait_for_completion+0x24
    [<ffffff8ac5acd0fc>] flush_work+0x180
    [<ffffff8ac6241af4>] ufshcd_link_recovery+0xfc
    [<ffffff8ac6241384>] ufshcd_uic_hibern8_enter+0x254
    [<ffffff8ac624cf74>] ufshcd_gate_work+0xc8
    [<ffffff8ac5ad0f28>] process_one_work+0x1c0
    [<ffffff8ac5ad13d4>] worker_thread+0x224
    [<ffffff8ac5ad627c>] kthread+0x120
    [<ffffff8ac5a84bd8>] ret_from_fork+0x10

Process: kworker/0:1, cpu: 0 pid: 81 start: 0xffffffdcf4f32280
    Task name: kworker/0:1 pid: 81 cpu: 0
    state: 0x2 exit_state: 0x0 stack base: 0xffffff8008418000
    Stack:
    [<ffffff8ac5a85d2c>] __switch_to+0xb8
    [<ffffff8ac6a7e654>] __schedule+0x690
    [<ffffff8ac6a7e8cc>] schedule+0x70
    [<ffffff8ac6a82218>] schedule_timeout+0x44
    [<ffffff8ac6a7fc5c>] do_wait_for_common+0xf0
    [<ffffff8ac6a7f970>] wait_for_common+0x58
    [<ffffff8ac6a7f90c>] wait_for_completion+0x24
    [<ffffff8ac5acd0fc>] flush_work+0x180
    [<ffffff8ac623f6b0>] ufshcd_hold+0x1cc
    [<ffffff8ac62447e8>] ufshcd_err_handler+0x71c
    [<ffffff8ac5ad0f28>] process_one_work+0x1c0
    [<ffffff8ac5ad13d4>] worker_thread+0x224
    [<ffffff8ac5ad627c>] kthread+0x120
    [<ffffff8ac5a84bd8>] ret_from_fork+0x10

Change-Id: I480ec14a24b4d4f7b10877b478facf744141d7e6
Signed-off-by: default avatarCan Guo <cang@codeaurora.org>
parent cf8acfa8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment