linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ido Yariv <ido@wizery.com>
To: Chris Ball <cjb@laptop.org>, Sekhar Nori <nsekhar@ti.com>,
	linux-mmc@vger.kernel.org,
	davinci-linux-open-source@linux.davincidsp.com
Cc: Ido Yariv <ido@wizery.com>
Subject: [PATCH REPOST 1/2] mmc: davinci: Eliminate spurious interrupts
Date: Sun, 11 Mar 2012 23:39:58 +0200	[thread overview]
Message-ID: <1331501999-13144-1-git-send-email-ido@wizery.com> (raw)
In-Reply-To: <B6A220404B6BFC4BBD2AB91C54D39DF43176B8CE@DBDE01.ent.ti.com>

The davinci mmc interrupt handler fills the fifo, as long as the DXRDY
or DRRDY bits are set in the status register.

If interrupts fire during this loop, they will be handled by the
handler, but the interrupt controller will still buffer these. As a
result, the handler will be called again to serve these needlessly. In
order to avoid these spurious interrupts, keep interrupts masked while
filling the fifo.

Signed-off-by: Ido Yariv <ido@wizery.com>
Tested-by: Rajashekhara, Sudhakar <sudhakar.raj@ti.com>
---
 drivers/mmc/host/davinci_mmc.c |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
index 64a8325..9cea66f 100644
--- a/drivers/mmc/host/davinci_mmc.c
+++ b/drivers/mmc/host/davinci_mmc.c
@@ -1009,12 +1009,33 @@ static irqreturn_t mmc_davinci_irq(int irq, void *dev_id)
 	 * by read. So, it is not unbouned loop even in the case of
 	 * non-dma.
 	 */
-	while (host->bytes_left && (status & (MMCST0_DXRDY | MMCST0_DRRDY))) {
-		davinci_fifo_data_trans(host, rw_threshold);
-		status = readl(host->base + DAVINCI_MMCST0);
-		if (!status)
-			break;
-		qstatus |= status;
+	if (host->bytes_left && (status & (MMCST0_DXRDY | MMCST0_DRRDY))) {
+		unsigned long im_val;
+
+		/*
+		 * If interrupts fire during the following loop, they will be
+		 * handled by the handler, but the PIC will still buffer these.
+		 * As a result, the handler will be called again to serve these
+		 * needlessly. In order to avoid these spurious interrupts,
+		 * keep interrupts masked during the loop.
+		 */
+		im_val = readl(host->base + DAVINCI_MMCIM);
+		writel(0, host->base + DAVINCI_MMCIM);
+
+		do {
+			davinci_fifo_data_trans(host, rw_threshold);
+			status = readl(host->base + DAVINCI_MMCST0);
+			qstatus |= status;
+		} while (host->bytes_left &&
+			 (status & (MMCST0_DXRDY | MMCST0_DRRDY)));
+
+		/*
+		 * If an interrupt is pending, it is assumed it will fire when
+		 * it is unmasked. This assumption is also taken when the MMCIM
+		 * is first set. Otherwise, writing to MMCIM after reading the
+		 * status is race-prone.
+		 */
+		writel(im_val, host->base + DAVINCI_MMCIM);
 	}
 
 	if (qstatus & MMCST0_DATDNE) {
-- 
1.7.7.6


  reply	other threads:[~2012-03-11 21:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4F1E9194.90608@mvista.com>
2012-01-24 11:16 ` [RFC 1/2] mmc: davinci: Eliminate spurious interrupts Ido Yariv
2012-01-24 11:16   ` [RFC 2/2] mmc: davinci: Poll status for small size transfers Ido Yariv
2012-01-27  8:11   ` [RFC 1/2] mmc: davinci: Eliminate spurious interrupts Rajashekhara, Sudhakar
2012-01-29 19:37     ` Ido Yariv
     [not found]   ` <1327403766-962-1-git-send-email-ido-Ix1uc/W3ht7QT0dZR+AlfA@public.gmane.org>
2012-01-31 11:30     ` Rajashekhara, Sudhakar
2012-03-11 21:39       ` Ido Yariv [this message]
2012-03-11 21:39         ` [PATCH REPOST 2/2] mmc: davinci: Poll status for small size transfers Ido Yariv
2012-03-16  3:32         ` [PATCH REPOST 1/2] mmc: davinci: Eliminate spurious interrupts Chris Ball

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1331501999-13144-1-git-send-email-ido@wizery.com \
    --to=ido@wizery.com \
    --cc=cjb@laptop.org \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=nsekhar@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).