Skip to content

Commit 7336060

Browse files
outman119gregkh
authored andcommitted
spi: nxp-xspi: Use reinit_completion() for repeated operations
[ Upstream commit 40f9bc6 ] 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: 29c8c00 ("spi: add driver for NXP XSPI controller") Reviewed-by: Haibo Chen <haibo.chen@nxp.com> Signed-off-by: Felix Gu <ustc.gu@gmail.com> Link: https://patch.msgid.link/20260304-spi-nxp-v2-1-cd7d7726a27e@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5005424 commit 7336060

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/spi/spi-nxp-xspi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ static int nxp_xspi_do_op(struct nxp_xspi *xspi, const struct spi_mem_op *op)
958958
writel(reg, base + XSPI_RBCT);
959959
}
960960

961-
init_completion(&xspi->c);
961+
reinit_completion(&xspi->c);
962962

963963
/* Config the data address */
964964
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)
12731273

12741274
nxp_xspi_default_setup(xspi);
12751275

1276+
init_completion(&xspi->c);
12761277
ret = devm_request_irq(dev, irq,
12771278
nxp_xspi_irq_handler, 0, pdev->name, xspi);
12781279
if (ret)

0 commit comments

Comments
 (0)