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.
Fixes: 29c8c00d9f9d ("spi: add driver for NXP XSPI controller")
Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/spi/spi-nxp-xspi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-nxp-xspi.c b/drivers/spi/spi-nxp-xspi.c
index 06fcdf22990b..385302a6e62f 100644
--- a/drivers/spi/spi-nxp-xspi.c
+++ b/drivers/spi/spi-nxp-xspi.c
@@ -958,7 +958,7 @@ static int nxp_xspi_do_op(struct nxp_xspi *xspi, const struct spi_mem_op *op)
writel(reg, base + XSPI_RBCT);
}
- init_completion(&xspi->c);
+ reinit_completion(&xspi->c);
/* Config the data address */
writel(op->addr.val + xspi->memmap_phy, base + XSPI_SFP_TG_SFAR);
@@ -1273,6 +1273,7 @@ static int nxp_xspi_probe(struct platform_device *pdev)
nxp_xspi_default_setup(xspi);
+ init_completion(&xspi->c);
ret = devm_request_irq(dev, irq,
nxp_xspi_irq_handler, 0, pdev->name, xspi);
if (ret)
--
2.43.0
On 26/03/04 08:47PM, Felix Gu wrote:
>
> The driver currently calls init_completion() during every spi_mem_op.
> Tchnically it may work, but it's not the recommended pattern.
Typo, Technically.
>
> 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.
>
> Fixes: 29c8c00d9f9d ("spi: add driver for NXP XSPI controller")
> Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
> drivers/spi/spi-nxp-xspi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-nxp-xspi.c b/drivers/spi/spi-nxp-xspi.c
> index 06fcdf22990b..385302a6e62f 100644
> --- a/drivers/spi/spi-nxp-xspi.c
> +++ b/drivers/spi/spi-nxp-xspi.c
> @@ -958,7 +958,7 @@ static int nxp_xspi_do_op(struct nxp_xspi *xspi, const struct spi_mem_op *op)
> writel(reg, base + XSPI_RBCT);
> }
>
> - init_completion(&xspi->c);
> + reinit_completion(&xspi->c);
>
> /* Config the data address */
> writel(op->addr.val + xspi->memmap_phy, base + XSPI_SFP_TG_SFAR);
> @@ -1273,6 +1273,7 @@ static int nxp_xspi_probe(struct platform_device *pdev)
>
> nxp_xspi_default_setup(xspi);
>
> + init_completion(&xspi->c);
> ret = devm_request_irq(dev, irq,
> nxp_xspi_irq_handler, 0, pdev->name, xspi);
> if (ret)
>
> --
> 2.43.0
>
From: Frank Li (AI-BOT) <frank.li@nxp.com> Typo in commit message: > Tchnically it may work, but it's not the recommended pattern. Should be "Technically" (missing 'e'). --- > So moves the initial initialization to probe function and uses Should be "So move the initial initialization..." or "This moves the initial initialization..." (subject-verb agreement). --- AI bot review and may be useless.
© 2016 - 2026 Red Hat, Inc.