From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from r3-17.sinamail.sina.com.cn (r3-17.sinamail.sina.com.cn [202.108.3.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0E1439FD4 for ; Thu, 5 Mar 2026 04:18:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.108.3.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772684316; cv=none; b=Ee87bGu4avdbtERXjdulI1toP5EyWehPyv3aUWgKbsRBOszPiBHAyIbvESiide/507jneobwI3kYlXkgTbHd+AK6xsI2ZTameIYeyQC9ohcW4FdUWH64nFW0H4DKOORz/fBEYL8iS9DybLHV9Bdf6eusc/Fac/UsfPvgSt1BizQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772684316; c=relaxed/simple; bh=favTZIXJG2CWfU8yJO7xDQZzhjWmYDKLlH8+aO6MbrU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dBXjl9ae2MSQRfr5dJ+OHsAAYgNNVS8kBOyGtaPI1seGF5KCRdvtH8Z5l8azszzbg9xZpkxoP3nOyy7Dg9PHrWVi5a6MlQF1nXos/rZRz9ktZkmFPfP03MdHKhiP3JmWNcdawqgm5YGEWJZveski4JU2nm5B0onjfLIZb3zaJDo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b=bn17jW6f; arc=none smtp.client-ip=202.108.3.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b="bn17jW6f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1772684313; bh=Npl5WUvYNLpW63TPWsVH+5F7JvbCkleBCD6qiZ+HkMQ=; h=From:Subject:Date:Message-ID; b=bn17jW6fZbbgpD7f85Fa2akBbj5vjlUD6UZvtfO4h08tmu8TxV4yRZjiAHIluwTZA 22c2XHp3geAZIeBMYMtuSogLSBmKtqKA+fJgZ2H8cBX2AVAYPL36wnkrmPFpYC4R4d 7m0jYrFBZl9vL13JuiO/L2ILBlgdnpD2ebuR6WRQ= X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([114.249.62.144]) by sina.com (10.54.253.34) with ESMTP id 69A903F100004C36; Thu, 5 Mar 2026 12:17:55 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 1762856292029 X-SMAIL-UIID: CC3245C390534F6C92739127E4A831DF-20260305-121755-1 From: Hillf Danton To: Felix Gu Cc: Han Xu , Haibo Chen , Mark Brown , Frank Li , Yogesh Narayan Gaur , linux-spi@vger.kernel.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] spi: nxp-fspi: Use reinit_completion() for repeated operations Date: Thu, 5 Mar 2026 12:17:45 +0800 Message-ID: <20260305041746.657-1-hdanton@sina.com> In-Reply-To: <20260304-spi-nxp-v2-2-cd7d7726a27e@gmail.com> References: <20260304-spi-nxp-v2-0-cd7d7726a27e@gmail.com> Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On Wed, 04 Mar 2026 20:47:20 +0800 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. > > 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: a5356aef6a90 ("spi: spi-mem: Add driver for NXP FlexSPI controller") > Signed-off-by: Felix Gu > --- > 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 > After this work relevant code in nxp_fspi_exec_op() looks like guard(mutex)(&f->lock); nxp_fspi_do_op() reinit_completion(&f->c); /* Wait for the interrupt. */ if (!wait_for_completion_timeout(&f->c, msecs_to_jiffies(1000))) err = -ETIMEDOUT; and if __no__ interrupt could fire after the 1000ms timeout, no reinit is needed at all. Otherwise reinit alone fails to work. Important is -- show the evidence that no chance is left for the timeout. BTW the same applies to other patches in this series?