Re: [PATCH v4 2/2] staging: mt7621-mmc: Initialize completions a single time during probe
From: Greg Kroah-Hartman
Date: Tue Mar 26 2019 - 20:46:20 EST
On Tue, Mar 26, 2019 at 09:21:39AM -0600, George Hilliard wrote:
> The module was initializing completions whenever it was going to wait on
> them, and not when the completion was allocated. This is incorrect
> according to the completion docs:
>
> Calling init_completion() on the same completion object twice is
> most likely a bug [...]
>
> Re-initialization is also unnecessary because the module never uses
> complete_all(). Fix this by only ever initializing the completion a
> single time, and log if the completions are not consumed as intended
> (this is not a fatal problem, but should not go unnoticed).
>
> Signed-off-by: George Hilliard <thirtythreeforty@xxxxxxxxx>
> ---
> v2: rewrite of v1
> v3: Remove BUG_ON() calls
> v4: Indent style fixup
>
> drivers/staging/mt7621-mmc/sd.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
> index e346167754bd..ed63bd3ba6cc 100644
> --- a/drivers/staging/mt7621-mmc/sd.c
> +++ b/drivers/staging/mt7621-mmc/sd.c
> @@ -466,7 +466,11 @@ static unsigned int msdc_command_start(struct msdc_host *host,
> host->cmd = cmd;
> host->cmd_rsp = resp;
>
> - init_completion(&host->cmd_done);
> + // The completion should have been consumed by the previous command
> + // response handler, because the mmc requests should be serialized
> + if(completion_done(&host->cmd_done))
Did you run your patch through checkpatch.pl? It should have reported
an error here :(