From patchwork Tue Jan 12 15:24:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ahmad Fatoum X-Patchwork-Id: 12013779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F31CCC433DB for ; Tue, 12 Jan 2021 15:27:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 85AC323130 for ; Tue, 12 Jan 2021 15:27:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85AC323130 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=NvLg4NiueOp3PsomDZai7l2dGrYloXPJh1La3hHliuM=; b=jRBeLdVmwlhYLRBRsih/8ruWYI 2YlM2ZuUmiU6FCjdobNop8/Kru+SfILmBwcJ9iGSHyjIudCnjYb1cwvdo19CAev8gNdcNGv4OaIpy FF/aT+Min8UvnDQtvX3i35aj3KVoMPO/see6VCkbyf2Ns822UKkJZTTrDQ/yRCvogAAg7QiGKuDxZ K+yIlnbt92WAZQA5m1Db4wH2Pi0kFpd5tlntOlh7hfXpkEhglROGU8Nd67eD7qyJoFxi1SwCXqXJ1 sggAcSsLYUz7BWefT9exOuuFlmj9j42WEwHISMQlzyRH7U8GTfLV38GKsoTZ8xhFyQqqtXwjje0Xq g0LnDS8w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzLYo-0002b8-Ml; Tue, 12 Jan 2021 15:26:18 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzLYl-0002Zb-CP for linux-arm-kernel@lists.infradead.org; Tue, 12 Jan 2021 15:26:16 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kzLYQ-0005FN-Rg; Tue, 12 Jan 2021 16:25:54 +0100 Received: from afa by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kzLYM-0005St-Si; Tue, 12 Jan 2021 16:25:50 +0100 From: Ahmad Fatoum To: Jonathan Cameron , Lars-Peter Clausen , Peter Meerwald-Stadler , Maxime Coquelin , Alexandre Torgue , Fabrice Gasnier , Olivier Moysan Subject: [PATCH] iio: adc: stm32-adc: fix erroneous handling of spurious IRQs Date: Tue, 12 Jan 2021 16:24:42 +0100 Message-Id: <20210112152441.20665-1-a.fatoum@pengutronix.de> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: afa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210112_102615_444402_8FC278F7 X-CRM114-Status: GOOD ( 18.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmad Fatoum , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, Holger Assmann , Thomas Gleixner , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Lucas Stach Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 1c6c69525b40 ("genirq: Reject bogus threaded irq requests") makes sure that threaded IRQs either - have IRQF_ONESHOT set - don't have the default just return IRQ_WAKE_THREAD primary handler This is necessary because level-triggered interrupts need to be masked, either at device or irqchip, to avoid an interrupt storm. For spurious interrupts, the STM32 ADC driver still does this bogus request though: - It doesn't set IRQF_ONESHOT - Its primary handler just returns IRQ_WAKE_THREAD if the interrupt is unexpected, i.e. !(status & enabled_mask) - stm32mp151.dtsi describes the ADC interrupt as level-triggered Fix this by setting IRQF_ONESHOT to have the irqchip mask the IRQ until the IRQ thread has finished. IRQF_ONESHOT also has the effect that the primary handler is no longer forced into a thread. This makes the issue with spurious interrupts interrupts disappear when reading the ADC on a threadirqs=1 kernel. This used to result in following kernel error message: iio iio:device1: Unexpected IRQ: IER=0x00000000, ISR=0x0000100e or iio iio:device1: Unexpected IRQ: IER=0x00000004, ISR=0x0000100a But with this patch applied (or threaded IRQs disabled), this no longer occurs. Cc: Lucas Stach Reported-by: Holger Assmann Fixes: 695e2f5c289b ("iio: adc: stm32-adc: fix a regression when using dma and irq") Signed-off-by: Ahmad Fatoum --- drivers/iio/adc/stm32-adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index c067c994dae2..7e0e21c79ac8 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -1910,7 +1910,7 @@ static int stm32_adc_probe(struct platform_device *pdev) ret = devm_request_threaded_irq(&pdev->dev, adc->irq, stm32_adc_isr, stm32_adc_threaded_isr, - 0, pdev->name, indio_dev); + IRQF_ONESHOT, pdev->name, indio_dev); if (ret) { dev_err(&pdev->dev, "failed to request IRQ\n"); return ret;