Re: [PATCH v1] Moving init_completion before request_irq

From: Martin Kaiser
Date: Sat Jul 30 2022 - 11:29:40 EST


Hello Kshitiz & Ahmad,

Thus wrote Ahmad Fatoum (a.fatoum@xxxxxxxxxxxxxx):

> > + init_completion(&rngc->rng_op_done);
> > +
> > ret = devm_request_irq(&pdev->dev,
> > irq, imx_rngc_irq, 0, pdev->name, (void *)rngc);

> This should probably be moved below imx_rngc_irq_mask_clear(rngc).
> init_completion can stay where it is. That way:

I agree with Ahmad that this is the better approach.

We should clear pending irqs and disable interrupt sources on the
hardware level before we install our irq handler.

Best regards,
Martin

> - You initialize rngc fully before registering the IRQ handler
> - You don't handle pending IRQs that you want to dismiss anyway
> - If the IRQ happens to be because of a SEED_DONE due to a previous
> boot stage, you don't end up completing the completion prematurely.