[net-next v1] net: wwan: t7xx: Fix FSM command timeout issue
Mateusz Polchlopek
mateusz.polchlopek at intel.com
Thu Dec 12 03:01:51 PST 2024
On 12/12/2024 11:55 AM, Jinjian Song wrote:
> When driver processes the internal state change command, it use
> asynchronous thread to process the command operation. If the main
> thread detects that the task has timed out, the asynchronous thread
> will panic when executing te completion notification because the
> main thread completion object is released.
>
> BUG: unable to handle page fault for address: fffffffffffffff8
> PGD 1f283a067 P4D 1f283a067 PUD 1f283c067 PMD 0
> Oops: 0000 [#1] PREEMPT SMP NOPTI
> RIP: 0010:complete_all+0x3e/0xa0
> [...]
> Call Trace:
> <TASK>
> ? __die_body+0x68/0xb0
> ? page_fault_oops+0x379/0x3e0
> ? exc_page_fault+0x69/0xa0
> ? asm_exc_page_fault+0x22/0x30
> ? complete_all+0x3e/0xa0
> fsm_main_thread+0xa3/0x9c0 [mtk_t7xx (HASH:1400 5)]
> ? __pfx_autoremove_wake_function+0x10/0x10
> kthread+0xd8/0x110
> ? __pfx_fsm_main_thread+0x10/0x10 [mtk_t7xx (HASH:1400 5)]
> ? __pfx_kthread+0x10/0x10
> ret_from_fork+0x38/0x50
> ? __pfx_kthread+0x10/0x10
> ret_from_fork_asm+0x1b/0x30
> </TASK>
> [...]
> CR2: fffffffffffffff8
> ---[ end trace 0000000000000000 ]---
>
> After the main thread determines that the task has timed out, mark
> the completion invalid, and add judgment in the asynchronous task.
>
> Signed-off-by: Jinjian Song <jinjian.song at fibocom.com>
> ---
> drivers/net/wwan/t7xx/t7xx_state_monitor.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wwan/t7xx/t7xx_state_monitor.c b/drivers/net/wwan/t7xx/t7xx_state_monitor.c
> index 3931c7a13f5a..57f1a7730fff 100644
> --- a/drivers/net/wwan/t7xx/t7xx_state_monitor.c
> +++ b/drivers/net/wwan/t7xx/t7xx_state_monitor.c
> @@ -108,7 +108,8 @@ static void fsm_finish_command(struct t7xx_fsm_ctl *ctl, struct t7xx_fsm_command
> {
> if (cmd->flag & FSM_CMD_FLAG_WAIT_FOR_COMPLETION) {
> *cmd->ret = result;
> - complete_all(cmd->done);
> + if (cmd->done)
> + complete_all(cmd->done);
> }
>
> kfree(cmd);
> @@ -503,8 +504,10 @@ int t7xx_fsm_append_cmd(struct t7xx_fsm_ctl *ctl, enum t7xx_fsm_cmd_state cmd_id
>
> wait_ret = wait_for_completion_timeout(&done,
> msecs_to_jiffies(FSM_CMD_TIMEOUT_MS));
> - if (!wait_ret)
> + if (!wait_ret) {
> + cmd->done = NULL;
> return -ETIMEDOUT;
> + }
>
> return ret;
> }
If this is a fix then should be targeted to net and not net-next
and probably should have Fixes: tag.
More information about the Linux-mediatek
mailing list