From patchwork Thu Jun 23 10:40:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 908622 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 p5NAf5JB031252 for ; Thu, 23 Jun 2011 10:41:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759225Ab1FWKlX (ORCPT ); Thu, 23 Jun 2011 06:41:23 -0400 Received: from mga09.intel.com ([134.134.136.24]:21043 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759157Ab1FWKlX (ORCPT ); Thu, 23 Jun 2011 06:41:23 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 23 Jun 2011 03:41:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.65,412,1304319600"; d="scan'208";a="18730982" Received: from unknown (HELO ahunter-desktop.localhost.com) ([10.255.17.28]) by orsmga001.jf.intel.com with ESMTP; 23 Jun 2011 03:41:22 -0700 From: Adrian Hunter To: Chris Ball Cc: linux-mmc , Adrian Hunter Subject: [PATCH 4/4] mmc: queue: bring discard_granularity/alignment into line with SCSI definitions Date: Thu, 23 Jun 2011 13:40:29 +0300 Message-Id: <1308825629-27375-5-git-send-email-adrian.hunter@intel.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1308825629-27375-1-git-send-email-adrian.hunter@intel.com> References: <1308825629-27375-1-git-send-email-adrian.hunter@intel.com> Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki 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]); Thu, 23 Jun 2011 10:41:37 +0000 (UTC) SCSI defines discard alignment as the offset to the first optimal discard. In the case of SD/MMC, that is always zero which is the default. SCSI defines discard granularity as a hint of a optimal discard size. That is much better expressed by the MMC "preferred erase size" (pref_erase) field. Signed-off-by: Adrian Hunter --- drivers/mmc/card/queue.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index 3e2db1c..6413afa 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c @@ -135,12 +135,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, mq->queue->limits.max_discard_sectors = UINT_MAX; if (card->erased_byte == 0) mq->queue->limits.discard_zeroes_data = 1; - if (!mmc_can_trim(card) && is_power_of_2(card->erase_size)) { - mq->queue->limits.discard_granularity = - card->erase_size << 9; - mq->queue->limits.discard_alignment = - card->erase_size << 9; - } + mq->queue->limits.discard_granularity = card->pref_erase << 9; if (mmc_can_secure_erase_trim(card)) queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, mq->queue);