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: 528781 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 p139bq30019956 for ; Thu, 3 Feb 2011 09:37:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755881Ab1BCJhv (ORCPT ); Thu, 3 Feb 2011 04:37:51 -0500 Received: from sand.ocn.ne.jp ([122.28.30.136]:55152 "EHLO smtp.sand.ocn.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755856Ab1BCJhu (ORCPT ); Thu, 3 Feb 2011 04:37:50 -0500 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 03 Feb 2011 09:37:52 +0000 (UTC) X-Greylist: delayed 1593 seconds by postgrey-1.27 at vger.kernel.org; Thu, 03 Feb 2011 04:37:50 EST 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 Cc: gilles.chanteperdrix@nexvision.fr, Jon Povey , Chris Ball , Andrew Morton , Kevin Hilman , Chaithrika U S , Anton Vorontsov , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org 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 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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