• Z
    ipmi: fix SSIF not responding under certain cond. · aaf2ccb4
    Zhang Yuchen 提交于
    stable inclusion
    from stable-v4.19.283
    commit ba810999356bffa4627985123c15327c692318e5
    category: bugfix
    bugzilla: https://gitee.com/openeuler/kernel/issues/I7BZ5U
    CVE: NA
    
    Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=ba810999356bffa4627985123c15327c692318e5
    
    --------------------------------
    
    [ Upstream commit 6d2555cd ]
    
    The ipmi communication is not restored after a specific version of BMC is
    upgraded on our server.
    The ipmi driver does not respond after printing the following log:
    
        ipmi_ssif: Invalid response getting flags: 1c 1
    
    I found that after entering this branch, ssif_info->ssif_state always
    holds SSIF_GETTING_FLAGS and never return to IDLE.
    
    As a result, the driver cannot be loaded, because the driver status is
    checked during the unload process and must be IDLE in shutdown_ssif():
    
            while (ssif_info->ssif_state != SSIF_IDLE)
                    schedule_timeout(1);
    
    The process trigger this problem is:
    
    1. One msg timeout and next msg start send, and call
    ssif_set_need_watch().
    
    2. ssif_set_need_watch()->watch_timeout()->start_flag_fetch() change
    ssif_state to SSIF_GETTING_FLAGS.
    
    3. In msg_done_handler() ssif_state == SSIF_GETTING_FLAGS, if an error
    message is received, the second branch does not modify the ssif_state.
    
    4. All retry action need IS_SSIF_IDLE() == True. Include retry action in
    watch_timeout(), msg_done_handler(). Sending msg does not work either.
    SSIF_IDLE is also checked in start_next_msg().
    
    5. The only thing that can be triggered in the SSIF driver is
    watch_timeout(), after destory_user(), this timer will stop too.
    
    So, if enter this branch, the ssif_state will remain SSIF_GETTING_FLAGS
    and can't send msg, no timer started, can't unload.
    
    We did a comparative test before and after adding this patch, and the
    result is effective.
    
    Fixes: 25930707 ("ipmi: Add SMBus interface driver (SSIF)")
    
    Cc: stable@vger.kernel.org
    Signed-off-by: NZhang Yuchen <zhangyuchen.lcr@bytedance.com>
    Message-Id: <20230412074907.80046-1-zhangyuchen.lcr@bytedance.com>
    Signed-off-by: NCorey Minyard <minyard@acm.org>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NYi Yang <yiyang13@huawei.com>
    Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
    Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
    aaf2ccb4
ipmi_ssif.c 49.9 KB