Linux-Renesas-SoC Archive on lore.kernel.org
 help / Atom feed
* [PATCH v2] mmc: tmio_mmc_core: don't claim spurious interrupts
@ 2019-02-09 19:13 Sergei Shtylyov
  2019-02-09 21:40 ` Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2019-02-09 19:13 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson, Wolfram Sang; +Cc: linux-renesas-soc

I have encountered an interrupt storm  during the eMMC chip probing (and
the chip finally didn't get detected). It  turned out  that U-Boot  left
the DMAC interrupts enabled while the  Linux driver didn't use those.
The SDHI driver's interrupt handler somehow  assumes that, even if an
SDIO interrupt didn't happen, it should return IRQ_HANDLED. I think that
if none of the enabled interrupts happened and got handled, we should
return IRQ_NONE -- that way the kernel IRQ code recoginizes a spurious
interrupt and masks  it off pretty quickly...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
The patch is against Ulf Hansson's 'mmc.git' repo's 'fixes' branch.
We  seem  to have dropped the ball on the version 1...

Changes in version 2:
- refreshed the patch;
- fixed an article and whitespace in the patch description.

 drivers/mmc/host/tmio_mmc_core.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Index: mmc/drivers/mmc/host/tmio_mmc_core.c
===================================================================
--- mmc.orig/drivers/mmc/host/tmio_mmc_core.c
+++ mmc/drivers/mmc/host/tmio_mmc_core.c
@@ -629,7 +629,7 @@ static bool __tmio_mmc_sdcard_irq(struct
 	return false;
 }
 
-static void __tmio_mmc_sdio_irq(struct tmio_mmc_host *host)
+static bool __tmio_mmc_sdio_irq(struct tmio_mmc_host *host)
 {
 	struct mmc_host *mmc = host->mmc;
 	struct tmio_mmc_data *pdata = host->pdata;
@@ -637,7 +637,7 @@ static void __tmio_mmc_sdio_irq(struct t
 	unsigned int sdio_status;
 
 	if (!(pdata->flags & TMIO_MMC_SDIO_IRQ))
-		return;
+		return false;
 
 	status = sd_ctrl_read16(host, CTL_SDIO_STATUS);
 	ireg = status & TMIO_SDIO_MASK_ALL & ~host->sdio_irq_mask;
@@ -650,6 +650,8 @@ static void __tmio_mmc_sdio_irq(struct t
 
 	if (mmc->caps & MMC_CAP_SDIO_IRQ && ireg & TMIO_SDIO_STAT_IOIRQ)
 		mmc_signal_sdio_irq(mmc);
+
+	return ireg ? true : false;
 }
 
 irqreturn_t tmio_mmc_irq(int irq, void *devid)
@@ -668,9 +670,10 @@ irqreturn_t tmio_mmc_irq(int irq, void *
 	if (__tmio_mmc_sdcard_irq(host, ireg, status))
 		return IRQ_HANDLED;
 
-	__tmio_mmc_sdio_irq(host);
+	if (__tmio_mmc_sdio_irq(host))
+		return IRQ_HANDLED;
 
-	return IRQ_HANDLED;
+	return IRQ_NONE;
 }
 EXPORT_SYMBOL_GPL(tmio_mmc_irq);
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] mmc: tmio_mmc_core: don't claim spurious interrupts
  2019-02-09 19:13 [PATCH v2] mmc: tmio_mmc_core: don't claim spurious interrupts Sergei Shtylyov
@ 2019-02-09 21:40 ` Wolfram Sang
  2019-02-10 17:35   ` Sergei Shtylyov
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2019-02-09 21:40 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-mmc, Ulf Hansson, Wolfram Sang, linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 794 bytes --]

On Sat, Feb 09, 2019 at 10:13:44PM +0300, Sergei Shtylyov wrote:
> I have encountered an interrupt storm  during the eMMC chip probing (and
> the chip finally didn't get detected). It  turned out  that U-Boot  left
> the DMAC interrupts enabled while the  Linux driver didn't use those.
> The SDHI driver's interrupt handler somehow  assumes that, even if an
> SDIO interrupt didn't happen, it should return IRQ_HANDLED. I think that
> if none of the enabled interrupts happened and got handled, we should
> return IRQ_NONE -- that way the kernel IRQ code recoginizes a spurious
> interrupt and masks  it off pretty quickly...
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

Looks OK in general.

> +	return ireg ? true : false;

	return ireg;

?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] mmc: tmio_mmc_core: don't claim spurious interrupts
  2019-02-09 21:40 ` Wolfram Sang
@ 2019-02-10 17:35   ` Sergei Shtylyov
  2019-02-10 17:49     ` Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2019-02-10 17:35 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-mmc, Ulf Hansson, Wolfram Sang, linux-renesas-soc

On 02/10/2019 12:40 AM, Wolfram Sang wrote:

>> I have encountered an interrupt storm  during the eMMC chip probing (and
>> the chip finally didn't get detected). It  turned out  that U-Boot  left
>> the DMAC interrupts enabled while the  Linux driver didn't use those.
>> The SDHI driver's interrupt handler somehow  assumes that, even if an
>> SDIO interrupt didn't happen, it should return IRQ_HANDLED. I think that
>> if none of the enabled interrupts happened and got handled, we should
>> return IRQ_NONE -- that way the kernel IRQ code recoginizes a spurious
>> interrupt and masks  it off pretty quickly...
>>
>> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
> 
> Looks OK in general.
> 
>> +	return ireg ? true : false;
> 
> 	return ireg;
> 
> ?

   How about !!ireg?

MBR, Sergei

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] mmc: tmio_mmc_core: don't claim spurious interrupts
  2019-02-10 17:35   ` Sergei Shtylyov
@ 2019-02-10 17:49     ` Wolfram Sang
  2019-02-11 16:37       ` Sergei Shtylyov
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2019-02-10 17:49 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-mmc, Ulf Hansson, Wolfram Sang, linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 238 bytes --]


> >> +	return ireg ? true : false;
> > 
> > 	return ireg;
> > 
> > ?
> 
>    How about !!ireg?

Better. Still, I wonder how this cast is gonna be different from the
cast being done because the return value is declared bool.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] mmc: tmio_mmc_core: don't claim spurious interrupts
  2019-02-10 17:49     ` Wolfram Sang
@ 2019-02-11 16:37       ` Sergei Shtylyov
  0 siblings, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2019-02-11 16:37 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-mmc, Ulf Hansson, Wolfram Sang, linux-renesas-soc

On 02/10/2019 08:49 PM, Wolfram Sang wrote:

>>>> +	return ireg ? true : false;
>>>
>>> 	return ireg;
>>>
>>> ?
>>
>>    How about !!ireg?
> 
> Better. Still, I wonder how this cast is gonna be different from the
> cast being done because the return value is declared bool.

   At least all the variants result in the same (quite bad) code with AArch64
and ARM gcc 4.8.5. Like this one:

	mov	w0, 1	// D.41524,
	cbnz	w23, .L353	// ireg,
.L297:
	mov	w0, 0	// D.41524,
	b	.L353	//

MBR, Sergei

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-09 19:13 [PATCH v2] mmc: tmio_mmc_core: don't claim spurious interrupts Sergei Shtylyov
2019-02-09 21:40 ` Wolfram Sang
2019-02-10 17:35   ` Sergei Shtylyov
2019-02-10 17:49     ` Wolfram Sang
2019-02-11 16:37       ` Sergei Shtylyov

Linux-Renesas-SoC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-renesas-soc/0 linux-renesas-soc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-renesas-soc linux-renesas-soc/ https://lore.kernel.org/linux-renesas-soc \
		linux-renesas-soc@vger.kernel.org linux-renesas-soc@archiver.kernel.org
	public-inbox-index linux-renesas-soc


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-renesas-soc


AGPL code for this site: git clone https://public-inbox.org/ public-inbox