From patchwork Wed Dec 8 11:45:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chuanxiao.Dong" X-Patchwork-Id: 390542 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 oB8BmqCG016503 for ; Wed, 8 Dec 2010 11:48:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754647Ab0LHLsm (ORCPT ); Wed, 8 Dec 2010 06:48:42 -0500 Received: from mga02.intel.com ([134.134.136.20]:12394 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751607Ab0LHLsl (ORCPT ); Wed, 8 Dec 2010 06:48:41 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 08 Dec 2010 03:48:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.59,315,1288594800"; d="scan'208";a="581727786" Received: from unknown (HELO intel.com) ([172.16.120.128]) by orsmga002.jf.intel.com with ESMTP; 08 Dec 2010 03:48:40 -0800 Date: Wed, 8 Dec 2010 19:45:11 +0800 From: Chuanxiao Dong To: linux-mmc@vger.kernel.org, adrian.hunter@nokia.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2]remove the erase calculation part from core.c Message-ID: <20101208114511.GB18249@intel.com> Reply-To: Chuanxiao Dong MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) 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.3 (demeter1.kernel.org [140.211.167.41]); Wed, 08 Dec 2010 11:48:53 +0000 (UTC) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 6286898..6d1b9e5 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1171,99 +1171,53 @@ void mmc_init_erase(struct mmc_card *card) } } -static void mmc_set_mmc_erase_timeout(struct mmc_card *card, - struct mmc_command *cmd, - unsigned int arg, unsigned int qty) +/* + * mmc_set_erase_timeout: set the cmd erase_timeout according + * to the argument type and erase groups count + */ +static void mmc_set_erase_timeout(struct mmc_card *card, + struct mmc_command *cmd, unsigned int arg, + unsigned int qty) { unsigned int erase_timeout; - if (card->ext_csd.erase_group_def & 1) { - /* High Capacity Erase Group Size uses HC timeouts */ - if (arg == MMC_TRIM_ARG) - erase_timeout = card->ext_csd.trim_timeout; - else - erase_timeout = card->ext_csd.hc_erase_timeout; + if (mmc_card_sd(card)) { + erase_timeout = card->erase_timeout * qty; + if (card->ssr.erase_timeout) + /* + * Erase timeout specified in SSR, + * plus erase_offset + * */ + erase_timeout += card->ssr.erase_offset; + /* Must not be less than 1 second */ + if (erase_timeout < 1000) + erase_timeout = 1000; } else { - /* CSD Erase Group Size uses write timeout */ - unsigned int mult = (10 << card->csd.r2w_factor); - unsigned int timeout_clks = card->csd.tacc_clks * mult; - unsigned int timeout_us; - - /* Avoid overflow: e.g. tacc_ns=80000000 mult=1280 */ - if (card->csd.tacc_ns < 1000000) - timeout_us = (card->csd.tacc_ns * mult) / 1000; - else - timeout_us = (card->csd.tacc_ns / 1000) * mult; - - /* - * ios.clock is only a target. The real clock rate might be - * less but not that much less, so fudge it by multiplying by 2. - */ - timeout_clks <<= 1; - timeout_us += (timeout_clks * 1000) / - (card->host->ios.clock / 1000); - - erase_timeout = timeout_us / 1000; - + if (arg & MMC_SECURE_ARGS) { + if (arg == MMC_SECURE_ERASE_ARG) + erase_timeout = qty * + card->sec_erase_timeout; + else + erase_timeout = qty * + card->sec_trim_timeout; + } else { + if (arg == MMC_TRIM_ARG) + erase_timeout = qty * + card->trim_timeout; + else + erase_timeout = qty * + card->erase_timeout; + } /* - * Theoretically, the calculation could underflow so round up - * to 1ms in that case. + * Ensure at least a 1 second timeout for SPI as per + * 'mmc_set_data_timeout()' */ - if (!erase_timeout) - erase_timeout = 1; - } - - /* Multiplier for secure operations */ - if (arg & MMC_SECURE_ARGS) { - if (arg == MMC_SECURE_ERASE_ARG) - erase_timeout *= card->ext_csd.sec_erase_mult; - else - erase_timeout *= card->ext_csd.sec_trim_mult; + if (mmc_host_is_spi(card->host) && erase_timeout < 1000) + erase_timeout = 1000; } - - erase_timeout *= qty; - - /* - * Ensure at least a 1 second timeout for SPI as per - * 'mmc_set_data_timeout()' - */ - if (mmc_host_is_spi(card->host) && erase_timeout < 1000) - erase_timeout = 1000; - cmd->erase_timeout = erase_timeout; } -static void mmc_set_sd_erase_timeout(struct mmc_card *card, - struct mmc_command *cmd, unsigned int arg, - unsigned int qty) -{ - if (card->ssr.erase_timeout) { - /* Erase timeout specified in SD Status Register (SSR) */ - cmd->erase_timeout = card->ssr.erase_timeout * qty + - card->ssr.erase_offset; - } else { - /* - * Erase timeout not specified in SD Status Register (SSR) so - * use 250ms per write block. - */ - cmd->erase_timeout = 250 * qty; - } - - /* Must not be less than 1 second */ - if (cmd->erase_timeout < 1000) - cmd->erase_timeout = 1000; -} - -static void mmc_set_erase_timeout(struct mmc_card *card, - struct mmc_command *cmd, unsigned int arg, - unsigned int qty) -{ - if (mmc_card_sd(card)) - mmc_set_sd_erase_timeout(card, cmd, arg, qty); - else - mmc_set_mmc_erase_timeout(card, cmd, arg, qty); -} - static int mmc_do_erase(struct mmc_card *card, unsigned int from, unsigned int to, unsigned int arg) {