All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] sdhci: Only handle CARD_INT for SDIO cards
@ 2017-01-02 18:23 Gabriel Krisman Bertazi
  2017-01-05  9:36 ` Adrian Hunter
  0 siblings, 1 reply; 3+ messages in thread
From: Gabriel Krisman Bertazi @ 2017-01-02 18:23 UTC (permalink / raw)
  To: ulf.hansson, adrian.hunter; +Cc: Gabriel Krisman Bertazi, linux-mmc

One of our kernelCI boxes hanged at boot because a faulty eSDHC device
was triggering spurious CARD_INT interrupts for SD cards, causing CMD52
reads, which are not allowed for SD devices.  This adds a sanity check
to the interruption path, preventing that illegal command from getting
sent to SD devices.

This quirk allows that particular machine to resume boot despite the
faulty hardware, instead of getting hung dealing with thousands of
mishandled interrupts.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
CC: Adrian Hunter <adrian.hunter@intel.com>
CC: Ulf Hansson <ulf.hansson@linaro.org>
CC: linux-mmc@vger.kernel.org
---
 drivers/mmc/host/sdhci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 23909804ffb8..43913876581e 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2665,6 +2665,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
 {
 	irqreturn_t result = IRQ_NONE;
 	struct sdhci_host *host = dev_id;
+	struct mmc_host *mmc = host->mmc;
 	u32 intmask, mask, unexpected = 0;
 	int max_loops = 16;
 
@@ -2733,7 +2734,9 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
 		if (intmask & SDHCI_INT_RETUNE)
 			mmc_retune_needed(host->mmc);
 
-		if (intmask & SDHCI_INT_CARD_INT) {
+		if (intmask & SDHCI_INT_CARD_INT && mmc->card &&
+		    (mmc->card->type == MMC_TYPE_SDIO ||
+		     mmc->card->type == MMC_TYPE_SD_COMBO)) {
 			sdhci_enable_sdio_irq_nolock(host, false);
 			host->thread_isr |= SDHCI_INT_CARD_INT;
 			result = IRQ_WAKE_THREAD;
-- 
2.11.0


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

* Re: [PATCH RESEND] sdhci: Only handle CARD_INT for SDIO cards
  2017-01-02 18:23 [PATCH RESEND] sdhci: Only handle CARD_INT for SDIO cards Gabriel Krisman Bertazi
@ 2017-01-05  9:36 ` Adrian Hunter
  2017-01-06 15:49   ` Gabriel Krisman Bertazi
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian Hunter @ 2017-01-05  9:36 UTC (permalink / raw)
  To: Gabriel Krisman Bertazi; +Cc: ulf.hansson, linux-mmc

On 02/01/17 20:23, Gabriel Krisman Bertazi wrote:
> One of our kernelCI boxes hanged at boot because a faulty eSDHC device
> was triggering spurious CARD_INT interrupts for SD cards, causing CMD52
> reads, which are not allowed for SD devices.  This adds a sanity check
> to the interruption path, preventing that illegal command from getting
> sent to SD devices.
> 
> This quirk allows that particular machine to resume boot despite the
> faulty hardware, instead of getting hung dealing with thousands of
> mishandled interrupts.
> 
> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
> CC: Adrian Hunter <adrian.hunter@intel.com>
> CC: Ulf Hansson <ulf.hansson@linaro.org>
> CC: linux-mmc@vger.kernel.org
> ---
>  drivers/mmc/host/sdhci.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 23909804ffb8..43913876581e 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2665,6 +2665,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
>  {
>  	irqreturn_t result = IRQ_NONE;
>  	struct sdhci_host *host = dev_id;
> +	struct mmc_host *mmc = host->mmc;
>  	u32 intmask, mask, unexpected = 0;
>  	int max_loops = 16;
>  
> @@ -2733,7 +2734,9 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
>  		if (intmask & SDHCI_INT_RETUNE)
>  			mmc_retune_needed(host->mmc);
>  
> -		if (intmask & SDHCI_INT_CARD_INT) {
> +		if (intmask & SDHCI_INT_CARD_INT && mmc->card &&
> +		    (mmc->card->type == MMC_TYPE_SDIO ||
> +		     mmc->card->type == MMC_TYPE_SD_COMBO)) {

We shouldn't have to look at the card type.  But if the interrupt is not
enabled, then we shouldn't process it.  What about:

		if (intmask & SDHCI_INT_CARD_INT &&
		    (host->ier & SDHCI_INT_CARD_INT)) {

>  			sdhci_enable_sdio_irq_nolock(host, false);
>  			host->thread_isr |= SDHCI_INT_CARD_INT;
>  			result = IRQ_WAKE_THREAD;
> 


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

* Re: [PATCH RESEND] sdhci: Only handle CARD_INT for SDIO cards
  2017-01-05  9:36 ` Adrian Hunter
@ 2017-01-06 15:49   ` Gabriel Krisman Bertazi
  0 siblings, 0 replies; 3+ messages in thread
From: Gabriel Krisman Bertazi @ 2017-01-06 15:49 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: ulf.hansson, linux-mmc

Adrian Hunter <adrian.hunter@intel.com> writes:

> On 02/01/17 20:23, Gabriel Krisman Bertazi wrote:
>> One of our kernelCI boxes hanged at boot because a faulty eSDHC device
>> was triggering spurious CARD_INT interrupts for SD cards, causing CMD52
>> reads, which are not allowed for SD devices.  This adds a sanity check
>> to the interruption path, preventing that illegal command from getting
>> sent to SD devices.
>> 
>> This quirk allows that particular machine to resume boot despite the
>> faulty hardware, instead of getting hung dealing with thousands of
>> mishandled interrupts.
>> 
>> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
>> CC: Adrian Hunter <adrian.hunter@intel.com>
>> CC: Ulf Hansson <ulf.hansson@linaro.org>
>> CC: linux-mmc@vger.kernel.org
>> ---
>>  drivers/mmc/host/sdhci.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>> index 23909804ffb8..43913876581e 100644
>> --- a/drivers/mmc/host/sdhci.c
>> +++ b/drivers/mmc/host/sdhci.c
>> @@ -2665,6 +2665,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
>>  {
>>  	irqreturn_t result = IRQ_NONE;
>>  	struct sdhci_host *host = dev_id;
>> +	struct mmc_host *mmc = host->mmc;
>>  	u32 intmask, mask, unexpected = 0;
>>  	int max_loops = 16;
>>  
>> @@ -2733,7 +2734,9 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
>>  		if (intmask & SDHCI_INT_RETUNE)
>>  			mmc_retune_needed(host->mmc);
>>  
>> -		if (intmask & SDHCI_INT_CARD_INT) {
>> +		if (intmask & SDHCI_INT_CARD_INT && mmc->card &&
>> +		    (mmc->card->type == MMC_TYPE_SDIO ||
>> +		     mmc->card->type == MMC_TYPE_SD_COMBO)) {
>
> We shouldn't have to look at the card type.  But if the interrupt is not
> enabled, then we shouldn't process it.  What about:

Hi Adrian,

Thanks for your review.  I think this way is ok too, I also ran it
against the faulty hardware and it prevented the hang as well.  I
just submitted a v2.

-- 
Gabriel Krisman Bertazi

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

end of thread, other threads:[~2017-01-06 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-02 18:23 [PATCH RESEND] sdhci: Only handle CARD_INT for SDIO cards Gabriel Krisman Bertazi
2017-01-05  9:36 ` Adrian Hunter
2017-01-06 15:49   ` Gabriel Krisman Bertazi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.