Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp873552pxb; Sat, 16 Jan 2021 09:55:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxklFSSnSgRVifvEYy4MHhm+9jhXFT592kH1yIooiZ1kO5B+xSJqFQCXn0F10jxHLoU+I1N X-Received: by 2002:a50:fc96:: with SMTP id f22mr14600272edq.162.1610819740717; Sat, 16 Jan 2021 09:55:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610819740; cv=none; d=google.com; s=arc-20160816; b=KKWCM4QbDpkUB6+UUegpgmZitsD+HBPamF6XTeCYhyf0EEY+eag9behM9o9TnCFD/L 98CCOnMXSGGbwoqrLslaIcd1ptO56CRNfsWj1OTPU4jcm8PfT5LavDsRasQv6BTQaWIU 51hC4lE+aJ6zhSmal2ir8cV5LAFOScQ3LzGsLnghcYSjOcGjFZUqLgDiHVmjB3yCZvNL qqFCASTCUyYs4bjchUS/fpzs4+9Xv+9VDqY66hgHaKBBqmJr8dXH7LWwHo6NVSwSaoLf jQF0kCENEn+zNTMlt4GhynHcmFzxp9uDupOh5ZH8CmeZ4UOfvtwWSVxKZgftznEVSPED +aQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=835plIVDYIDQnv3QN3MGmIPtyxx8dGQywHo3QnDfvGM=; b=Pk3sFG6Jmul19CMLpvHR5TWuCgYUseDNhezDbZqYtjYJItTM2dLKb4F60cMJXC1Cd3 fB6p3gdvI/QGC0GTeDEYjq9Nm6owZ9O0+kGley3wdpP2r3DH7jKrmZak1iizMNCSLfSS 42ypsEoS2o/F1hl7EINxcBnBSxqcE3N2G6wlDvZNn88mB4AmWM8rG3b0WX3HfctJq7v8 V9I+DmAlXOlXGi38GbbFSM09g1/F/f6+iKgUyqddrtpXaYEvr1YCkIi3YEfvDz40vaT9 toXaOR7IN7dZ4yVKHOz6esznmeyPmdRotaJN5Rx95FU3EmRYPA1rNaK9cERYfYSkaZkL xUJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si6308039edd.509.2021.01.16.09.55.17; Sat, 16 Jan 2021 09:55:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727522AbhAPRyT (ORCPT + 99 others); Sat, 16 Jan 2021 12:54:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:38902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbhAPRyT (ORCPT ); Sat, 16 Jan 2021 12:54:19 -0500 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 Cc: Lars-Peter Clausen , Peter Meerwald-Stadler , Maxime Coquelin , Alexandre Torgue , Fabrice Gasnier , Olivier Moysan , kernel@pengutronix.de, Thomas Gleixner , Lucas Stach , Holger Assmann , linux-iio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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;