On 2024/8/2 0:20, Bart Van Assche wrote: > On 8/1/24 5:32 AM, Junxian Huang wrote: >> Besides, exchange the order of INIT_WORK() and srpt_refresh_port() >> in srpt_add_one(), so that when srpt_refresh_port() failed, there >> is no need to cancel the work in this iteration. > > The above description is wrong. There is no need to cancel work after > INIT_WORK() has been called if the work has never been queued. Hence, > moving the INIT_WORK() call is not necessary. > Well, inspired by your comment I looked into the code again and I think perhaps this whole patch is not necessary. I encountered this problem in 5.10 kernel, where ib_register_event_handler() was called before the for-loop. But this bug has been fixed in the current mainline, and the work won't be queued until the whole for-loop is finished. Thanks, Junxian >> @@ -3220,7 +3221,6 @@ static int srpt_add_one(struct ib_device *device) >> sport->port_attrib.srp_max_rsp_size = DEFAULT_MAX_RSP_SIZE; >> sport->port_attrib.srp_sq_size = DEF_SRPT_SQ_SIZE; >> sport->port_attrib.use_srq = false; >> - INIT_WORK(&sport->work, srpt_refresh_port_work); >> ret = srpt_refresh_port(sport); >> if (ret) { >> @@ -3229,6 +3229,8 @@ static int srpt_add_one(struct ib_device *device) >> i--; >> goto err_port; >> } >> + >> + INIT_WORK(&sport->work, srpt_refresh_port_work); >> } > > I don't think that this change is necessary. > > Bart. >