From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3E6FCC6B34 for ; Thu, 15 Oct 2026 07:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pMYu6XVNal0AJcS3PUZBVy2r/rGrO8ylXWPO84VbQeo=; b=eWqtRcTgSIJO7kkY69AiE1asgp +HPTR0Hx2ajNflcsN/9tM2LsU47fBpjqv2CqyiCAXcym87DCAI6WSSYWD10rWQrCuH8mL4LMDNmJH TP3gPPCWmvOuMTobmCw8DpNtONtUMAD9np48BndKfLJ4VAmpzycPUsZn3GZ8ZErGIjmJ5XSiucwSo E+pvhbbcL5wW4UHh1nzKcMQqcvwvOylWXDk9q1kCd1YoOtJUJFbjZ96zDQ/8FW2QjbzYEFMwJxM0h vtef6TrKKi/ZG1d/Sw16qqu+MdoqLycSC4Znep/f3R3pSkHlTPjUqQBfF8FUDbTN/DyAekoofQ2Fm r+xJQroA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xHFkn-0000000H1f8-3Y63; Thu, 15 Oct 2026 07:19:53 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xHFkl-0000000H1eb-1Gq2; Thu, 15 Oct 2026 07:19:52 +0000 Date: Thu, 15 Oct 2026 09:19:43 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1792048785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pMYu6XVNal0AJcS3PUZBVy2r/rGrO8ylXWPO84VbQeo=; b=2dhabvrmaiB4B2VAEeswkB7yZk+pT6F/neoH/LS31NDI2EasvjB3yVv4534B6du3DDiMSw gMrc965fNvSGCVlP87f6uNl3leecQv3nIZRDmwfmb8S2h/cJW559zsz1m+2w3dBJKq/Ruc CwYvgSTmAKPw18wco3hfv5EYFXB0cfCf1E5PBGBQET2HTHFjkzd2aEsSZKUubuexi86NZu 9JjQ++YpNiWDfm8w5sPlbjl7kAfi5zXU47N+ESy5a776vyVgUcr93gLbDSCiqK1Q+sWEDr PfqofcDMr1vdOjhET3/jJZnJZC2gee+wkLn2s1LESxe+zvqTtxnEuGerbM2Mdg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1792048785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pMYu6XVNal0AJcS3PUZBVy2r/rGrO8ylXWPO84VbQeo=; b=AkUw+EUCmsaDH+sGC2dLGo8hwRAJMoyzJ70p9vgVLsV/6hgT9AkOw03tMby+l6jzeW5i4D mP6nSW669f2bkfAg== From: Sebastian Andrzej Siewior To: James Hilliard Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Clark Williams , Steven Rostedt , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Maxime Ripard , Richard Genoud , Boris Brezillon , Masahiro Yamada , Brian Norris , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, devicetree@vger.kernel.org Subject: Re: [PATCH v7 04/16] mtd: rawnand: sunxi: drain interrupts before reusing the completion Message-ID: <20261015071943.7OihPadq@linutronix.de> References: <20261014-submit-sunxi-nand-vendor-oob-layout-v1-v7-0-5d3fc6ad2da1@gmail.com> <20261014-submit-sunxi-nand-vendor-oob-layout-v1-v7-4-5d3fc6ad2da1@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20261014-submit-sunxi-nand-vendor-oob-layout-v1-v7-4-5d3fc6ad2da1@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261015_001951_507639_DBD551C3 X-CRM114-Status: GOOD ( 13.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2026-10-14 19:33:51 [-0600], James Hilliard wrote: > --- a/drivers/mtd/nand/raw/sunxi_nand.c > +++ b/drivers/mtd/nand/raw/sunxi_nand.c > @@ -454,16 +457,19 @@ static int sunxi_nfc_wait_events(struct sunxi_nfc *nfc, u32 events, > timeout_ms = NFC_DEFAULT_TIMEOUT_MS; > > if (!use_polling) { > - init_completion(&nfc->complete); > + reinit_completion(&nfc->complete); > > writel(events, nfc->regs + NFC_REG_INT); > > ret = wait_for_completion_timeout(&nfc->complete, > msecs_to_jiffies(timeout_ms)); > - if (!ret) > + if (!ret) { > + /* Drain the handler before it can restore an old IRQ mask. */ > + disable_irq(nfc->irq); > ret = -ETIMEDOUT; > - else > + } else { > ret = 0; > + } > > writel(0, nfc->regs + NFC_REG_INT); > } else { > @@ -476,6 +482,12 @@ static int sunxi_nfc_wait_events(struct sunxi_nfc *nfc, u32 events, > > writel(events & NFC_INT_MASK, nfc->regs + NFC_REG_ST); > > + if (!use_polling && ret) { > + /* Flush the mask and acknowledgment before re-enabling the IRQ. */ > + readl(nfc->regs + NFC_REG_INT); > + enable_irq(nfc->irq); Shouldn't you re-read NFC_REG_ST, checking if the event became true even in the case of a timeout? Say the interrupt wake the thread but the thread never had a chance to run. The timer (on another CPU) had a chance to run and did wake this thread. Checking the event in the timeout case would help to prevent that. > + } > + > if (ret) > dev_err(nfc->dev, "wait interrupt timedout\n"); > Sebastian