RE: [PATCH v2 2/3] spi: nxp-fspi: Use reinit_completion() for repeated operations
From: Bough Chen
Date: Sun Mar 08 2026 - 22:30:47 EST
> -----Original Message-----
> From: Felix Gu <ustc.gu@xxxxxxxxx>
> Sent: 2026年3月4日 20:47
> To: Han Xu <han.xu@xxxxxxx>; Bough Chen <haibo.chen@xxxxxxx>; Mark
> Brown <broonie@xxxxxxxxxx>; Frank Li <frank.li@xxxxxxx>; Yogesh Gaur
> <yogeshgaur.83@xxxxxxxxx>; Yogesh Narayan Gaur
> <yogeshnarayan.gaur@xxxxxxx>; Boris Brezillon <bbrezillon@xxxxxxxxxx>;
> Frieder Schrempf <frieder.schrempf@xxxxxxxxxx>
> Cc: linux-spi@xxxxxxxxxxxxxxx; imx@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
> Felix Gu <ustc.gu@xxxxxxxxx>
> Subject: [PATCH v2 2/3] spi: nxp-fspi: Use reinit_completion() for repeated
> operations
>
> The driver currently calls init_completion() during every spi_mem_op.
> Tchnically it may work, but it's not the recommended pattern.
>
> According to the kernel documentation: 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.
>
> So moves the initial initialization to probe function and uses
> reinit_completion() for subsequent operations.
Reviewed-by: Haibo Chen <haibo.chen@xxxxxxx>
Regards
Haibo Chen
>
> Fixes: a5356aef6a90 ("spi: spi-mem: Add driver for NXP FlexSPI controller")
> Signed-off-by: Felix Gu <ustc.gu@xxxxxxxxx>
> ---
> drivers/spi/spi-nxp-fspi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c index
> 320b3d93df57..1e36ae084dd8 100644
> --- a/drivers/spi/spi-nxp-fspi.c
> +++ b/drivers/spi/spi-nxp-fspi.c
> @@ -996,7 +996,7 @@ static int nxp_fspi_do_op(struct nxp_fspi *f, const struct
> spi_mem_op *op)
> reg = reg | FSPI_IPRXFCR_CLR;
> fspi_writel(f, reg, base + FSPI_IPRXFCR);
>
> - init_completion(&f->c);
> + reinit_completion(&f->c);
>
> fspi_writel(f, op->addr.val, base + FSPI_IPCR0);
> /*
> @@ -1365,6 +1365,7 @@ static int nxp_fspi_probe(struct platform_device
> *pdev)
> if (ret < 0)
> return dev_err_probe(dev, ret, "Failed to disable clock");
>
> + init_completion(&f->c);
> ret = devm_request_irq(dev, irq,
> nxp_fspi_irq_handler, 0, pdev->name, f);
> if (ret)
>
> --
> 2.43.0