public inbox for linux-spi@vger.kernel.org
 help / color / mirror / Atom feed
From: Felix Gu <ustc.gu@gmail.com>
To: Han Xu <han.xu@nxp.com>, Haibo Chen <haibo.chen@nxp.com>,
	 Mark Brown <broonie@kernel.org>, Frank Li <Frank.Li@nxp.com>,
	 Yogesh Gaur <yogeshgaur.83@gmail.com>,
	 Yogesh Narayan Gaur <yogeshnarayan.gaur@nxp.com>,
	 Boris Brezillon <bbrezillon@kernel.org>,
	 Frieder Schrempf <frieder.schrempf@kontron.de>
Cc: linux-spi@vger.kernel.org, imx@lists.linux.dev,
	 linux-kernel@vger.kernel.org, Felix Gu <ustc.gu@gmail.com>
Subject: [PATCH v2 1/3] spi: nxp-xspi: Use reinit_completion() for repeated operations
Date: Wed, 04 Mar 2026 20:47:19 +0800	[thread overview]
Message-ID: <20260304-spi-nxp-v2-1-cd7d7726a27e@gmail.com> (raw)
In-Reply-To: <20260304-spi-nxp-v2-0-cd7d7726a27e@gmail.com>

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


  reply	other threads:[~2026-03-04 12:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04 12:47 [PATCH v2 0/3] spi: nxp: Use reinit_completion() for repeated operations Felix Gu
2026-03-04 12:47 ` Felix Gu [this message]
2026-03-04 14:55   ` [PATCH v2 1/3] spi: nxp-xspi: " Frank Li
2026-03-05  0:13   ` Han Xu
2026-03-04 12:47 ` [PATCH v2 2/3] spi: nxp-fspi: " Felix Gu
2026-03-05  4:17   ` Hillf Danton
2026-03-09  2:23   ` Bough Chen
2026-03-04 12:47 ` [PATCH v2 3/3] spi: fsl-qspi: " Felix Gu
2026-03-04 14:55   ` Frank Li
2026-03-09  2:23   ` Bough Chen
2026-03-09 23:22 ` [PATCH v2 0/3] spi: nxp: " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260304-spi-nxp-v2-1-cd7d7726a27e@gmail.com \
    --to=ustc.gu@gmail.com \
    --cc=Frank.Li@nxp.com \
    --cc=bbrezillon@kernel.org \
    --cc=broonie@kernel.org \
    --cc=frieder.schrempf@kontron.de \
    --cc=haibo.chen@nxp.com \
    --cc=han.xu@nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=yogeshgaur.83@gmail.com \
    --cc=yogeshnarayan.gaur@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox