On Wed, 2025-03-12 at 07:25 -0700, Bart Van Assche wrote: > > > > Hi Bart, > > > > This could calling init_completion on the same completion twice? > > Hi Peter, > > My patch will cause init_completion() to be called as many times as > device management commands are submitted. As far as I know the > following > sequence is allowed and does not trigger any race conditions: > > Thread 1 Thread 2 > -------- -------- > init_completion() > wait_for_completion_timeout() is called > complete() > wait_for_completion_timeout() returns > > init_completion() > wait_for_completion_timeout() is called > complete() > wait_for_completion_timeout() returns > > [ ... ] > > Thanks, > > Bart. Hi Bart, https://www.kernel.org/doc/Documentation/scheduler/completion.txt Calling init_completion() on the same completion object twice is most likely a bug as it re-initializes the queue to an empty queue and enqueued tasks could get "lost" - use reinit_completion() in that case, but be aware of other races. I understand that it should be protected from racing issues by the dev_cmd.lock, but it's probably best not to use it in this way. Using reinit_completion might be a better approach. Thanks. Peter