Re: [PATCH v5 2/2] mfd: loongson-se: Fix miscellaneous issues
From: Qunqin Zhao
Date: Wed Aug 05 2026 - 05:44:30 EST
在 2026/8/4 22:29, Huacai Chen 写道:
On Tue, Aug 4, 2026 at 10:09 AM Qunqin Zhao <zhaoqunqin@xxxxxxxxxxx> wrote:
In my opinion, if a function can be called multiple times, we need
在 2026/8/3 16:01, Huacai Chen 写道:
Hi, Qunqin,To prevent an spurious interrupt from completing an uninitialized object,
On Thu, Jul 30, 2026 at 4:41 PM Qunqin Zhao <zhaoqunqin@xxxxxxxxxxx> wrote:
int loongson_se_send_engine_cmd(struct loongson_se_engine *engine)
{
+ int err;
+
+ mutex_lock(&engine->se->cmd_lock);
+
+ reinit_completion(&engine->completion);
+
/*
* After engine initialization, the controller already knows
* where to obtain engine commands from. Now all we need to
* do is notify the controller that the engine needs to be started.
*/
- int err = loongson_se_poll(engine->se, BIT(engine->id));
+ err = loongson_se_poll(engine->se, BIT(engine->id));
+
+ mutex_unlock(&engine->se->cmd_lock);
if (err)
return err;
@@ -97,7 +109,7 @@ struct loongson_se_engine *loongson_se_init_engine(struct device *dev, int id)
engine->se = se;
engine->id = id;
- init_completion(&engine->completion);
+ reinit_completion(&engine->completion);
I'm not sure, but I think loongson_se_init_engine() is only called at
init, so we need init_completion here.
all objects have already been fully initialized with init_completion during the probe stage.
reinit_completion(), if it is only called for probe, we need
init_completion(), and loongson_se_init_engine() looks like the later
case.
I'm not sure. If init_completion twice works too, let's go with init_completion then.
Thanks
Huacai