linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Alexander Stein <alexander.stein@systec-electronic.com>
Cc: Chris Ball <cjb@laptop.org>,
	Jesse Barnes <jbarnes@virtuousgeek.org>,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH 2/3] mmc: sdhci: check interrupt flags in ISR again
Date: Wed, 14 Mar 2012 09:39:02 +0200	[thread overview]
Message-ID: <4F604B16.606@intel.com> (raw)
In-Reply-To: <1331659002-13743-2-git-send-email-alexander.stein@systec-electronic.com>

On 13/03/12 19:16, Alexander Stein wrote:
> When using MSI it is possible that a new MSI is sent while an earlier
> MSI is currently handled. In this case SDHCI_INT_STATUS only contains
> SDHCI_INT_RESPONSE and the ISR would not be called again. But at the end
> of the ISR SDHCI_INT_DATA_END is now also pending which would be ignored.
> 
> Fix this by rereading the interrupt flags in the ISR until no interrupt
> we care is pending.
> 
> Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
> ---
>  drivers/mmc/host/sdhci.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 8d66706..654ab32 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2268,6 +2268,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
>  	irqreturn_t result;
>  	struct sdhci_host *host = dev_id;
>  	u32 intmask;
> +	u32 intmask_unhandled;
>  	int cardint = 0;
>  
>  	spin_lock(&host->lock);
> @@ -2286,6 +2287,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
>  		goto out;
>  	}
>  
> +again:
>  	DBG("*** %s got interrupt: 0x%08x\n",
>  		mmc_hostname(host->mmc), intmask);
>  
> @@ -2336,6 +2338,14 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
>  		sdhci_writel(host, SDHCI_INT_BUS_POWER, SDHCI_INT_STATUS);
>  	}
>  
> +	intmask_unhandled = intmask;
> +
> +	intmask = sdhci_readl(host, SDHCI_INT_STATUS);
> +
> +	/* Do interrupt handling again if we got new flags */
> +	if (intmask & ~intmask_unhandled)
> +		goto again;
> +
>  	intmask &= ~SDHCI_INT_BUS_POWER;
>  
>  	if (intmask & SDHCI_INT_CARD_INT)

Why not just replace mmiowb() i.e.


diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 8d66706..da8a101 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2353,7 +2353,9 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)

        result = IRQ_HANDLED;

-       mmiowb();
+       intmask = sdhci_readl(host, SDHCI_INT_STATUS);
+       if (intmask)
+               goto again;
 out:
        spin_unlock(&host->lock);


But maybe it would be safer limiting the number of loops i.e.


diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 8d66706..d88247d 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2268,7 +2268,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
        irqreturn_t result;
        struct sdhci_host *host = dev_id;
        u32 intmask;
-       int cardint = 0;
+       int cardint = 0, max_loops = 16;

        spin_lock(&host->lock);

@@ -2353,7 +2353,9 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)

        result = IRQ_HANDLED;

-       mmiowb();
+       intmask = sdhci_readl(host, SDHCI_INT_STATUS);
+       if (intmask && --max_loops)
+               goto again;
 out:
        spin_unlock(&host->lock);



  reply	other threads:[~2012-03-14  7:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-13 17:16 [PATCH 1/3] mmc: sdhci-pci: Add MSI support Alexander Stein
2012-03-13 17:16 ` [PATCH 2/3] mmc: sdhci: check interrupt flags in ISR again Alexander Stein
2012-03-14  7:39   ` Adrian Hunter [this message]
2012-03-14  7:53     ` Alexander Stein
2012-03-14  8:13       ` Adrian Hunter
2012-03-14  8:52         ` [PATCH v2] " Alexander Stein
2012-03-14  9:23           ` Adrian Hunter
2012-03-13 17:16 ` [PATCH 3/3] mmc: sdhci-pci: allow 8-bit bus width for Intel PCH Alexander Stein
2012-03-13 17:25   ` Greg KH
2012-03-14  7:38     ` [PATCH v2] " Alexander Stein
2012-03-14  1:17   ` [PATCH 3/3] " Tomoya MORINAGA
2012-03-14  7:26     ` Alexander Stein
2012-03-16  3:41 ` [PATCH 1/3] mmc: sdhci-pci: Add MSI support 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=4F604B16.606@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=alexander.stein@systec-electronic.com \
    --cc=cjb@laptop.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /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).