From patchwork Wed Jun 15 13:28:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 881862 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5FDSZlY021730 for ; Wed, 15 Jun 2011 13:28:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753337Ab1FON2f (ORCPT ); Wed, 15 Jun 2011 09:28:35 -0400 Received: from moutng.kundenserver.de ([212.227.126.171]:59123 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754173Ab1FON2e (ORCPT ); Wed, 15 Jun 2011 09:28:34 -0400 Received: from axis700.grange (dslb-094-221-122-162.pools.arcor-ip.net [94.221.122.162]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0LtDvX-1PVltA0qPD-0127DE; Wed, 15 Jun 2011 15:28:27 +0200 Received: by axis700.grange (Postfix, from userid 1000) id 7E2B6E6AB4; Wed, 15 Jun 2011 15:28:25 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id 73908189B82; Wed, 15 Jun 2011 15:28:25 +0200 (CEST) Date: Wed, 15 Jun 2011 15:28:25 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: linux-mmc@vger.kernel.org cc: Chris Ball Subject: [PATCH/RFC] mmc: ignore asynchronous calls on dead buses Message-ID: MIME-Version: 1.0 X-Provags-ID: V02:K0:r9has0UKlxocDZp0QScUa2DEewMuC3NelLAtSXdv5Oz WSKEgjy6SNHdWRp1mf6ns6qkFkUzztijO9dBLwoAG/dJQDLX34 MUumole7AUgKBm0MpYBE3pMS67HY6indS+ZE2rrgChNqNmhu3D ROBbfS5Nwy+exEatwK8vwFkafnLb8OE9pZEdtVPK7eCWDfS/72 TkbnufjxfnEz3hX5dcQopg+lBC37tPoOFJc1KYohrU= 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]); Wed, 15 Jun 2011 13:28:36 +0000 (UTC) MMC host drivers have three main asynchronous event types, that they report to the MMC core: request completions, SDIO interrupts and card hotplug events. Avoid processing these calls during driver removal. Signed-off-by: Guennadi Liakhovetski --- This is my attempt to answer my own question: http://article.gmane.org/gmane.linux.kernel.mmc/8280 All these races are very unlikely, but can be triggered artificially by inserting a delay in host drivers after mmc_remove_host(). -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 68091dd..c11e47b 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -95,6 +95,9 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) struct mmc_command *cmd = mrq->cmd; int err = cmd->error; + if (host->bus_dead) + return; + if (err && cmd->retries && mmc_host_is_spi(host)) { if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) cmd->retries = 0; @@ -1162,7 +1165,8 @@ void mmc_detect_change(struct mmc_host *host, unsigned long delay) spin_unlock_irqrestore(&host->lock, flags); #endif - mmc_schedule_delayed_work(&host->detect, delay); + if (!host->bus_dead) + mmc_schedule_delayed_work(&host->detect, delay); } EXPORT_SYMBOL(mmc_detect_change); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 1ee4424..1a1f2a4 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -311,6 +311,9 @@ extern void mmc_request_done(struct mmc_host *, struct mmc_request *); static inline void mmc_signal_sdio_irq(struct mmc_host *host) { + if (host->bus_dead) + return; + host->ops->enable_sdio_irq(host, 0); wake_up_process(host->sdio_irq_thread); }