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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 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 39171C433DB for ; Sat, 16 Jan 2021 17:56:07 +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 E36DF2245C for ; Sat, 16 Jan 2021 17:56:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E36DF2245C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zmL2C/3O7Jui9dJXtTaASqepoxD7duE9joqu42we2jQ=; b=AcPYGHOM278j56rO7U6b46EOz EASQTP6sB9N0vy2KgVktg8cdSXN6ikFUEQ9S0dgUvhPNHsrmvsmwflwFRbY7sOoDwlEgoUSsk3TNJ YrcSMk7kKXSJ6OnUijXbw6c5diY0un0WEUpCWpQeXnemdwIDQGrfhZYTru2a7ppcdxT766MDBlBja pl4aFNjagKGWD3x46N4ZQJInv5FiOVF2T3ovL+Oat4quXWF9g2AgxO9Pm5Vm86tCT0U7PWimtJiOg rDg40CrQz/pCY+XuSlNmYBPKHMP1SrXt7lA96stJRkERSuMkHjgyNGuzyaP40FooK1SViXrjtimLT eJEJjQ2kA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0plf-0004Cf-UG; Sat, 16 Jan 2021 17:53:43 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0pld-0004CG-9b for linux-arm-kernel@lists.infradead.org; Sat, 16 Jan 2021 17:53:42 +0000 Received: from archlinux (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED47A2246B; Sat, 16 Jan 2021 17:53:36 +0000 (UTC) Date: Sat, 16 Jan 2021 17:53:33 +0000 From: Jonathan Cameron To: Ahmad Fatoum Subject: Re: [PATCH] iio: adc: stm32-adc: fix erroneous handling of spurious IRQs Message-ID: <20210116175333.4d8684c5@archlinux> In-Reply-To: <20210112152441.20665-1-a.fatoum@pengutronix.de> References: <20210112152441.20665-1-a.fatoum@pengutronix.de> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210116_125341_464566_B8EBA031 X-CRM114-Status: GOOD ( 28.74 ) 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: Lars-Peter Clausen , Olivier Moysan , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , Lucas Stach , Holger Assmann , Thomas Gleixner , Fabrice Gasnier , kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, Alexandre Torgue Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 12 Jan 2021 16:24:42 +0100 Ahmad Fatoum wrote: > 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) This seems 'unusual'. If this is a spurious interrupt we should be returning IRQ_NONE and letting the spurious interrupt protection stuff kick in. The only reason I can see that it does this is print an error message. I'm not sure why we need to go into the thread to do that given it's not supposed to happen. If we need that message at all, I'd suggest doing it in the interrupt handler then return IRQ_NONE; > - 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; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel