linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Venkatraman S <svenkatr@ti.com>
To: <linux-mmc@vger.kernel.org>, <cjb@laptop.org>,
	<linux-mm@kvack.org>, <linux-fsdevel@vger.kernel.org>,
	<linux-omap@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <arnd.bergmann@linaro.org>,
	<alex.lemberg@sandisk.com>, <ilan.smith@sandisk.com>,
	<lporzio@micron.com>, <rmk+kernel@arm.linux.org.uk>,
	Venkatraman S <svenkatr@ti.com>
Subject: [PATCH v2 15/16] mmc: Update preempted request with CORRECTLY_PRG_SECTORS_NUM info
Date: Thu, 3 May 2012 19:53:14 +0530	[thread overview]
Message-ID: <1336054995-22988-16-git-send-email-svenkatr@ti.com> (raw)
In-Reply-To: <1336054995-22988-1-git-send-email-svenkatr@ti.com>

Ongoing request that was preempted during 'programming' state is partially
completed. Number of correctly programmed sectors is available in the
ext_csd field CORRECTLY_PRG_SECTORS_NUM. Read this field to update
the bytes_xfered field of the request

Signed-off-by: Venkatraman S <svenkatr@ti.com>
---
 drivers/mmc/core/core.c |   26 ++++++++++++++++++++++++--
 include/linux/mmc/mmc.h |    4 ++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index e6430f8..354dd7a 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -122,6 +122,23 @@ static inline void mmc_should_fail_request(struct mmc_host *host,
 
 #endif /* CONFIG_FAIL_MMC_REQUEST */
 
+static int mmc_get_programmed_sectors(struct mmc_card *card, int *nsectors)
+{
+	int err;
+	u8 ext_csd[512];
+
+	mmc_claim_host(card->host);
+	err = mmc_send_ext_csd(card, ext_csd);
+	mmc_release_host(card->host);
+	if (err)
+		return err;
+	*nsectors = ext_csd[EXT_CSD_C_PRG_SECTORS_NUM0] +
+			(ext_csd[EXT_CSD_C_PRG_SECTORS_NUM1] << 7) +
+			(ext_csd[EXT_CSD_C_PRG_SECTORS_NUM2] << 15) +
+			(ext_csd[EXT_CSD_C_PRG_SECTORS_NUM3] << 23);
+
+	return 0;
+}
 /**
  *	mmc_request_done - finish processing an MMC request
  *	@host: MMC host which completed request
@@ -470,6 +487,7 @@ int mmc_preempt_foreground_request(struct mmc_card *card,
 	struct mmc_request *req)
 {
 	int ret;
+	int nsectors;
 
 	ret = mmc_abort_req(card->host, req);
 	if (ret == -ENOSYS)
@@ -490,8 +508,12 @@ int mmc_preempt_foreground_request(struct mmc_card *card,
 	 */
 	if (req->data && req->data->error) {
 		mmc_interrupt_hpi(card);
-		/* TODO : Take out the CORRECTLY_PRG_SECTORS_NUM
-		 * from ext_csd and add it to the request */
+
+		ret = mmc_get_programmed_sectors(card, &nsectors);
+		if (ret)
+			req->data->bytes_xfered = 0;
+		else
+			req->data->bytes_xfered = nsectors * 512;
 	}
 
 	return 0;
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index ec2f195..4a3453f 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -315,6 +315,10 @@ struct _mmc_csd {
 #define EXT_CSD_PWR_CL_200_360		237	/* RO */
 #define EXT_CSD_PWR_CL_DDR_52_195	238	/* RO */
 #define EXT_CSD_PWR_CL_DDR_52_360	239	/* RO */
+#define EXT_CSD_C_PRG_SECTORS_NUM0	242	/* RO */
+#define EXT_CSD_C_PRG_SECTORS_NUM1	243	/* RO */
+#define EXT_CSD_C_PRG_SECTORS_NUM2	244	/* RO */
+#define EXT_CSD_C_PRG_SECTORS_NUM3	245	/* RO */
 #define EXT_CSD_POWER_OFF_LONG_TIME	247	/* RO */
 #define EXT_CSD_GENERIC_CMD6_TIME	248	/* RO */
 #define EXT_CSD_CACHE_SIZE		249	/* RO, 4 bytes */
-- 
1.7.10.rc2


  parent reply	other threads:[~2012-05-03 14:25 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-03 14:22 [PATCHv2 00/16] [FS, MM, block, MMC]: eMMC High Priority Interrupt Feature Venkatraman S
2012-05-03 14:23 ` [PATCH v2 01/16] FS: Added demand paging markers to filesystem Venkatraman S
2012-05-06 23:31   ` Dave Chinner
2012-05-07 16:46     ` S, Venkatraman
2012-05-09  0:33       ` Dave Chinner
2012-05-09 13:59         ` Arnd Bergmann
2012-05-09 15:03           ` Christoph Hellwig
2012-05-09 16:54             ` Arnd Bergmann
2012-05-09 15:27       ` Vivek Goyal
     [not found]     ` <CAB+TZU8FNWuHrf6Hqnjs5fwH8yMJgd=CLPB0iUkrs2a-fgehtQ@mail.gmail.com>
2012-05-08 16:35       ` S, Venkatraman
2012-05-03 14:23 ` [PATCH v2 02/16] MM: Added page swapping markers to memory management Venkatraman S
2012-05-03 14:23 ` [PATCH v2 03/16] block: add queue attributes to manage dpmg and swapin requests Venkatraman S
2012-05-03 14:23 ` [PATCH v2 04/16] block: add sysfs attributes for runtime control of dpmg and swapin Venkatraman S
2012-05-03 14:23 ` [PATCH v2 05/16] block: Documentation: add sysfs ABI for expedite_dmpg and expedite_swapin Venkatraman S
2012-05-03 14:23 ` [PATCH v2 06/16] block: treat DMPG and SWAPIN requests as special Venkatraman S
2012-05-03 14:38   ` Jeff Moyer
2012-05-03 16:22     ` S, Venkatraman
2012-05-03 14:23 ` [PATCH v2 07/16] mmc: core: helper function for finding preemptible command Venkatraman S
2012-05-03 14:23 ` [PATCH v2 08/16] mmc: core: add preemptibility tracking fields to mmc command Venkatraman S
2012-05-03 14:23 ` [PATCH v2 09/16] mmc: core: Add MMC abort interface Venkatraman S
2012-05-03 14:23 ` [PATCH v2 10/16] mmc: block: Detect HPI support in card and host controller Venkatraman S
2012-05-03 14:23 ` [PATCH v2 11/16] mmc: core: Implement foreground request preemption procedure Venkatraman S
2012-05-03 14:23 ` [PATCH v2 12/16] mmc: sysfs: Add sysfs entry for tuning preempt_time_threshold Venkatraman S
2012-05-03 14:23 ` [PATCH v2 13/16] mmc: Documentation: Add sysfs ABI for hpi_time_threshold Venkatraman S
2012-05-03 14:23 ` [PATCH v2 14/16] mmc: block: Implement HPI invocation and handling logic Venkatraman S
2012-05-09  8:35   ` kdorfman
2012-05-09 14:01     ` Arnd Bergmann
2012-05-09 14:06     ` S, Venkatraman
2012-05-03 14:23 ` Venkatraman S [this message]
2012-05-03 14:23 ` [PATCH v2 16/16] mmc: omap_hsmmc: Implement abort_req host_ops Venkatraman S
2012-05-08  7:46 ` [PATCHv2 00/16] [FS, MM, block, MMC]: eMMC High Priority Interrupt Feature Minchan Kim
2012-05-08 16:31   ` S, Venkatraman
2012-05-09  0:45     ` Minchan Kim
2012-05-11 19:18       ` S, Venkatraman
     [not found]       ` <CAB+TZU-r6aYn8WRZjZ0DojxMTMoc5MSx7c93W0pAad1coscPwQ@mail.gmail.com>
2012-05-14  7:55         ` Minchan Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336054995-22988-16-git-send-email-svenkatr@ti.com \
    --to=svenkatr@ti.com \
    --cc=alex.lemberg@sandisk.com \
    --cc=arnd.bergmann@linaro.org \
    --cc=cjb@laptop.org \
    --cc=ilan.smith@sandisk.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=lporzio@micron.com \
    --cc=rmk+kernel@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).