From patchwork Thu Feb 3 09:10:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Povey X-Patchwork-Id: 528771 Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p139DUFE006481 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 3 Feb 2011 09:13:51 GMT Received: from dlep35.itg.ti.com ([157.170.170.118]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id p139BMxu016677 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 3 Feb 2011 03:11:22 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id p139BLFt003482; Thu, 3 Feb 2011 03:11:22 -0600 (CST) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id C099C80627; Thu, 3 Feb 2011 03:11:21 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id CED9F80626 for ; Thu, 3 Feb 2011 03:11:20 -0600 (CST) Received: from neches.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id p139BIxS018818 for ; Thu, 3 Feb 2011 03:11:18 -0600 (CST) Received: from psmtp.com (na3sys009amx258.postini.com [74.125.149.142]) by neches.ext.ti.com (8.13.7/8.13.7) with SMTP id p139BHiO005927 for ; Thu, 3 Feb 2011 03:11:17 -0600 Received: from source ([122.28.30.136]) by na3sys009amx258.postini.com ([74.125.148.10]) with SMTP; Thu, 03 Feb 2011 03:11:17 CST Received: from localhost.localdomain (p4129-ipbf6309marunouchi.tokyo.ocn.ne.jp [114.145.195.129]) by smtp.sand.ocn.ne.jp (Postfix) with ESMTP id 5A1502510; Thu, 3 Feb 2011 18:11:14 +0900 (JST) From: Jon Povey To: davinci-linux-open-source@linux.davincidsp.com Subject: [RFC] mmc: davinci: fix corruption after surprise card eject Date: Thu, 3 Feb 2011 18:10:33 +0900 Message-Id: <1296724233-3903-1-git-send-email-jon.povey@racelogic.co.uk> X-Mailer: git-send-email 1.6.3.3 X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:73.22153/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: Kevin Hilman , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Anton Vorontsov , Andrew Morton , Chris Ball X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 03 Feb 2011 09:13:51 +0000 (UTC) diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index 33d9f1b..e5ee1c1 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c @@ -795,6 +795,9 @@ static void calculate_clk_divider(struct mmc_host *mmc, struct mmc_ios *ios) } } +static void +davinci_abort_data(struct mmc_davinci_host *host, struct mmc_data *data); + static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) { struct mmc_davinci_host *host = mmc_priv(mmc); @@ -856,9 +859,14 @@ static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) } if (lose) dev_warn(mmc_dev(host->mmc), "powerup timeout\n"); - } - /* FIXME on power OFF, reset things ... */ + } else if (ios->power_mode == MMC_POWER_OFF) { + + /* Controller maybe in bad state, e.g. card pulled while writing */ + davinci_abort_data(host, NULL); + + /* FIXME on power OFF, reset more things ...? */ + } } static void