Skip to contentSkip to conversation

Avoid needless loop in sdhci_irq() for Card Interrupt

PATCH In review Alexey Neyman 3 participants 8 messages Nov 4, 2013 – Nov 26, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

[Patch ping #3: anyone interested in making sdhci_irq a bit faster?]

Hi all,

I've discovered that the sdhci_irq() function needlessly iterates re-reading the interrupt status and doing nothing (until it runs out of max_loops) when it handles the "Card Interrupt" status in the interrupt status register.

The reason is that the "Card Interrupt" bit is not cleared until the sdhci_irq() calls mmc_signal_sdio_irq(), so if Card Interrupt was asserted, re-reading the interrupt status will find this bit set over and over, even if no other bits are reported.

The fix: ignore Card Interrupt bits in the interrupt status if we already know that mmc_signal_sdio_irq() is going to be called at the end of sdhci_irq().

commit 7f23315b344ca51ddf22a78f326f88404fa8c81d

Author: Alexey Neyman <[email protected]>
Date:   Wed Oct 9 22:23:54 2013 -0700

Avoid a loop in sdhci.c.

drivers/mmc/host/sdhci.c +8 -0
index 7a7fb4f..a83cd1b 100644
@@ -2491,6 +2491,14 @@ again:
 	result = IRQ_HANDLED;
 
 	intmask = sdhci_readl(host, SDHCI_INT_STATUS);
+
+	/*
+	 * If we know we'll call the driver to signal SDIO IRQ, disregard
+	 * further indications of Card Interrupt in the status to avoid a
+	 * needless loop.
+	 */
+	if (cardint)
+		intmask &= ~SDHCI_INT_CARD_INT;
 	if (intmask && --max_loops)
 		goto again;
 out:
#1 lore raw

Hi Alexey,

Quoted 13 lines · Alexey Neyman

[Patch ping #3: anyone interested in making sdhci_irq a bit faster?]

Hi all,

I've discovered that the sdhci_irq() function needlessly iterates re-reading the interrupt status and doing nothing (until it runs out of max_loops) when it handles the "Card Interrupt" status in the interrupt status register.

The reason is that the "Card Interrupt" bit is not cleared until the sdhci_irq() calls mmc_signal_sdio_irq(), so if Card Interrupt was asserted, re-reading the interrupt status will find this bit set over and over, even if no other bits are reported.

Quoted 4 lines

The fix: ignore Card Interrupt bits in the interrupt status if we already know that mmc_signal_sdio_irq() is going to be called at the end of sdhci_irq().

I also noticed this issue.
Your fix looks correct to me.
But as following community working way, you need send out patches formerly, not attach a diff file.
You can refer to 'git send-email' or try with gmail.

BTW, please enrich your patch commit message.

Regards
Dong Aisheng

#2 lore raw

PATCH 1/1 Avoid needless loop in sdhci_irq()

Ignore Card Interrupt bit in the interrupt status if we already know that mmc_signal_sdio_irq() is going to be called at the end of sdhci_irq(). This avoids a needless loop in sdhci_irq() repeatedly reading interrupt status and doing nothing.

---
 drivers/mmc/host/sdhci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mmc/host/sdhci.c +8 -0
index 7a7fb4f..a83cd1b 100644
@@ -2491,6 +2491,14 @@ again:
 	result = IRQ_HANDLED;
 
 	intmask = sdhci_readl(host, SDHCI_INT_STATUS);
+
+	/*
+	 * If we know we'll call the driver to signal SDIO IRQ, disregard
+	 * further indications of Card Interrupt in the status to avoid a
+	 * needless loop.
+	 */
+	if (cardint)
+		intmask &= ~SDHCI_INT_CARD_INT;
 	if (intmask && --max_loops)
 		goto again;
 out:
Signature · 1 line
1.8.4.1
Acked-by on v1 1/1
#3 lore raw

Re: [PATCH] Avoid needless loop in sdhci_irq()

Quoted 6 lines · Alexey Neyman

Ignore Card Interrupt bit in the interrupt status if we already know that mmc_signal_sdio_irq() is going to be called at the end of sdhci_irq(). This avoids a needless loop in sdhci_irq() repeatedly reading interrupt status and doing nothing.

You need improve the patch title a bit, like:
mmc: sdhci: avoid needless loop for handle SDIO interrupts in sdhci_irq

Otherwise,

You could resend with my ack.

Regards
Dong Aisheng

Quoted 31 lines
---
 drivers/mmc/host/sdhci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mmc/host/sdhci.c +8 -1
index 7a7fb4f..a83cd1b 100644
@@ -2491,6 +2491,14 @@ again:
        result = IRQ_HANDLED;
 
        intmask = sdhci_readl(host, SDHCI_INT_STATUS);
+
+       /*
+        * If we know we'll call the driver to signal SDIO IRQ, disregard
+        * further indications of Card Interrupt in the status to avoid a
+        * needless loop.
+        */
+       if (cardint)
+               intmask &= ~SDHCI_INT_CARD_INT;
        if (intmask && --max_loops)
                goto again;
 out:
--

1.8.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw

PATCH 1/1 mmc: sdhci: Avoid needless loop while handling SDIO interrupts in sdhci_irq()

Ignore Card Interrupt bit in the interrupt status if we already know that mmc_signal_sdio_irq() is going to be called at the end of sdhci_irq(). This avoids a needless loop in sdhci_irq() repeatedly reading interrupt status and doing nothing.

---
 drivers/mmc/host/sdhci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mmc/host/sdhci.c +8 -0
index 7a7fb4f..a83cd1b 100644
@@ -2491,6 +2491,14 @@ again:
 	result = IRQ_HANDLED;
 
 	intmask = sdhci_readl(host, SDHCI_INT_STATUS);
+
+	/*
+	 * If we know we'll call the driver to signal SDIO IRQ, disregard
+	 * further indications of Card Interrupt in the status to avoid a
+	 * needless loop.
+	 */
+	if (cardint)
+		intmask &= ~SDHCI_INT_CARD_INT;
 	if (intmask && --max_loops)
 		goto again;
 out:
Signature · 1 line
1.8.4.1
#5 lore raw

Re: [PATCH] mmc: sdhci: Avoid needless loop while handling SDIO interrupts in sdhci_irq()

Hi Alexey,

Quoted 20 lines · Alexey Neyman

Ignore Card Interrupt bit in the interrupt status if we already know that mmc_signal_sdio_irq() is going to be called at the end of sdhci_irq(). This avoids a needless loop in sdhci_irq() repeatedly reading interrupt status and doing nothing.

---
 drivers/mmc/host/sdhci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mmc/host/sdhci.c +1 -0
index 7a7fb4f..a83cd1b 100644
@@ -2491,6 +2491,14 @@ again:
 	result = IRQ_HANDLED;
 
 	intmask = sdhci_readl(host, SDHCI_INT_STATUS);
+

drivers/mmc/host/sdhci.c again: · line 2504

Quoted 10 lines
drivers/mmc/host/sdhci.c +7 -0
+	/*
+	 * If we know we'll call the driver to signal SDIO IRQ, disregard
+	 * further indications of Card Interrupt in the status to avoid a
+	 * needless loop.
+	 */
+	if (cardint)
+		intmask &= ~SDHCI_INT_CARD_INT;
 	if (intmask && --max_loops)
 		goto again;
 out:

Thanks, pushed to mmc-next for 3.13.

- Chris.

Signature · 1 line
Chris Ball   <[email protected]>   <http://printf.net/>
#6 lore raw

Re: [PATCH] mmc: sdhci: Avoid needless loop while handling SDIO interrupts in sdhci_irq()

In reply to Alexey Neyman

[yet another patch ping]

Quoted 30 lines · Alexey Neyman

Ignore Card Interrupt bit in the interrupt status if we already know that mmc_signal_sdio_irq() is going to be called at the end of sdhci_irq(). This avoids a needless loop in sdhci_irq() repeatedly reading interrupt status and doing nothing.

---
 drivers/mmc/host/sdhci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mmc/host/sdhci.c +8 -0
index 7a7fb4f..a83cd1b 100644
@@ -2491,6 +2491,14 @@ again:
 	result = IRQ_HANDLED;
 
 	intmask = sdhci_readl(host, SDHCI_INT_STATUS);
+
+	/*
+	 * If we know we'll call the driver to signal SDIO IRQ, disregard
+	 * further indications of Card Interrupt in the status to avoid a
+	 * needless loop.
+	 */
+	if (cardint)
+		intmask &= ~SDHCI_INT_CARD_INT;
 	if (intmask && --max_loops)
 		goto again;
 out:
#7 lore raw

Re: [PATCH] mmc: sdhci: Avoid needless loop while handling SDIO interrupts in sdhci_irq()

In reply to Alexey Neyman

Hi Alexey,

Quoted 20 lines · Alexey Neyman

Ignore Card Interrupt bit in the interrupt status if we already know that mmc_signal_sdio_irq() is going to be called at the end of sdhci_irq(). This avoids a needless loop in sdhci_irq() repeatedly reading interrupt status and doing nothing.

---
 drivers/mmc/host/sdhci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/mmc/host/sdhci.c +1 -0
index 7a7fb4f..a83cd1b 100644
@@ -2491,6 +2491,14 @@ again:
 	result = IRQ_HANDLED;
 
 	intmask = sdhci_readl(host, SDHCI_INT_STATUS);
+

drivers/mmc/host/sdhci.c again: · line 2504

Quoted 10 lines
drivers/mmc/host/sdhci.c +7 -0
+	/*
+	 * If we know we'll call the driver to signal SDIO IRQ, disregard
+	 * further indications of Card Interrupt in the status to avoid a
+	 * needless loop.
+	 */
+	if (cardint)
+		intmask &= ~SDHCI_INT_CARD_INT;
 	if (intmask && --max_loops)
 		goto again;
 out:

Thanks, this was included in 3.13-rc1 via mmc-next.

- Chris.

Signature · 1 line
Chris Ball   <[email protected]>   <http://printf.net/>