Re: [PATCH v5 2/2] mfd: loongson-se: Fix miscellaneous issues

Qunqin Zhao <[email protected]>
Newsgroups dev.linux.lists.loongarch,org.kernel.vger.linux-crypto,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
在 2026/8/4 22:29, Huacai Chen 写道:
> On Tue, Aug 4, 2026 at 10:09 AM Qunqin Zhao <[email protected]> wrote:
>>
>> 在 2026/8/3 16:01, Huacai Chen 写道:
>>> Hi, Qunqin,
>>>
>>> On Thu, Jul 30, 2026 at 4:41 PM Qunqin Zhao <[email protected]> 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.
>> To prevent an spurious interrupt from completing an uninitialized object,
>> all objects have already been fully initialized with init_completion during the probe stage.
> In my opinion, if a function can be called multiple times, we need
> 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
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.