From patchwork Tue May 31 21:52:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 834092 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4VLqx98012154 for ; Tue, 31 May 2011 21:52:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932579Ab1EaVw7 (ORCPT ); Tue, 31 May 2011 17:52:59 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:61051 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758348Ab1EaVw6 (ORCPT ); Tue, 31 May 2011 17:52:58 -0400 Received: by pzk9 with SMTP id 9so2218413pzk.19 for ; Tue, 31 May 2011 14:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=18Mtzeyrd+JHGyjl2qUy5wZ5+4bivu3A1sl1SPmNcQQ=; b=lvGV2CpdPVq0lsCLU79tRkhQHMrhZb81Wj1LewHZHgQBsGaPBpxJNsKs0k12+gGm1t 6z5p6nUIFjapMpLZr4c44Y98OZOe81Q6R5IaQfMj9cU7yZXreeJOwPQplbT/5lYAaQ/Q TNlNnBCMhWpUCEjLSakmH53ZMshTnnRkgaqpc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=jCMN8CfS4IA8xtdqpPKOuGvDmPwaJtAmyRC5+Cz2PurI+tugpulGusrv0WHh45sh/q jgEJwUDwW+XSribVIwSSYjZW6dGaArSmxYPYh28akAr2/U071EM9aHDK33zrh10NgA8d seigIWbxHEIh8GbC/EnRvYK22yj2lbnOuem0g= MIME-Version: 1.0 Received: by 10.68.4.194 with SMTP id m2mr2520846pbm.228.1306878777866; Tue, 31 May 2011 14:52:57 -0700 (PDT) Received: by 10.68.40.41 with HTTP; Tue, 31 May 2011 14:52:57 -0700 (PDT) In-Reply-To: <1306874008-28867-1-git-send-email-per.forlin@linaro.org> References: <1306874008-28867-1-git-send-email-per.forlin@linaro.org> Date: Tue, 31 May 2011 22:52:57 +0100 X-Google-Sender-Auth: wjWQrmvG01N-in2Rh4uswAB8-J0 Message-ID: Subject: Re: [PATCH 0/2] sdio: make sdio_single_irq optional due to suprious IRQ From: Daniel Drake To: Per Forlin Cc: linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Nicolas Pitre , linaro-dev@lists.linaro.org, Chris Ball Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 31 May 2011 21:52:59 +0000 (UTC) On 31 May 2011 21:33, Per Forlin wrote: > Daniel Drake reported an issue in the libertas sdio client that was > triggered by the sdio_single_irq functionality. His SDIO device seems to > raise an interrupt even though there are no bits set in the CCCR_INTx > register. This behaviour is not supported by the sdio_single_irq feature nor > the SDIO spec. The purpose of the sdio_single_irq feature is to avoid the > overhead of checking the CCCR_INTx registers, this result in no error > handling of the case if there is a pending IRQ with none CCCR_INTx bits set. Thanks a lot for diagnosing this and nice work on figuring out the root cause presumably without even having access to the hardware! I've looked further, based on your findings, and have found that you are correct. During initialisation, exactly one interrupt is received with CCCR_INTx=0. Previously the mmc stack threw this interrupt away, after the optimization it now calls into libertas before it is ready to handle interrupts, leading to the crash. From that point, all other interrupts that come in are "normal". This is definitely a weird hardware issue, and it would annoy me for this hardware to cause a second generic mmc layer feature be disabled by default! And actually it is not much work to harden up the libertas driver to be able to accept that spurious IRQ, and during the process of fixing that it actually made the spurious IRQ go away completely. Patch attached. So, I vote for that we work around this little hardware issue in the libertas driver, and leave this optimization enabled by default until we find a hardware issue that is more difficult to workaround. I can take on submission of the libertas patch. Thoughts? Daniel diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c index a7b5cb0..224e985 100644 --- a/drivers/net/wireless/libertas/if_sdio.c +++ b/drivers/net/wireless/libertas/if_sdio.c @@ -907,7 +907,7 @@ static void if_sdio_interrupt(struct sdio_func *func) card = sdio_get_drvdata(func); cause = sdio_readb(card->func, IF_SDIO_H_INT_STATUS, &ret); - if (ret) + if (ret || !cause) goto out; lbs_deb_sdio("interrupt: 0x%X\n", (unsigned)cause); @@ -1008,10 +1008,6 @@ static int if_sdio_probe(struct sdio_func *func, if (ret) goto release; - ret = sdio_claim_irq(func, if_sdio_interrupt); - if (ret) - goto disable; - /* For 1-bit transfers to the 8686 model, we need to enable the * interrupt flag in the CCCR register. Set the MMC_QUIRK_LENIENT_FN0 * bit to allow access to non-vendor registers. */ @@ -1083,6 +1079,21 @@ static int if_sdio_probe(struct sdio_func *func, card->rx_unit = 0; /* + * Set up the interrupt handler late. + * + * If we set it up earlier, the (buggy) hardware generates a spurious + * interrupt, even before the interrupt has been enabled, with + * CCCR_INTx = 0. + * + * We register the interrupt handler late so that we can handle any + * spurious interrupts, and also to avoid generation of that known + * spurious interrupt in the first place. + */ + ret = sdio_claim_irq(func, if_sdio_interrupt); + if (ret) + goto disable; + + /* * Enable interrupts now that everything is set up */ sdio_writeb(func, 0x0f, IF_SDIO_H_INT_MASK, &ret);