From: Chuanxiao Dong <chuanxiao.dong@intel.com>
To: linux-mmc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, cjb@laptop.org,
akpm@linux-foundation.org, arjan@linux.intel.com,
alan@linux.intel.com, kmpark@infradead.org
Subject: [PATCH v2 4/4]use HPI to interrupt BKOPS
Date: Fri, 3 Dec 2010 20:14:43 +0800 [thread overview]
Message-ID: <20101203121443.GE18655@intel.com> (raw)
>From d759e4606c498c63cbeae2ed00adf6c289acac6f Mon Sep 17 00:00:00 2001
From: Chuanxiao Dong <chuanxiao.dong@intel.com>
Date: Fri, 3 Dec 2010 19:34:15 +0800
Subject: [PATCH 4/4] mmc: Add HPI operation to interrupt BKOPS
Before start a new user request, driver need to wait until the
BKOPS finished, or use HPI to interrupt the BKOPS since user request
has a higher priority than BKOPS.
This patch can let driver use HPI command to interrupt BKOPS.
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
---
drivers/mmc/core/core.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 51 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 4190424..4ac6c56 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -202,6 +202,51 @@ static void mmc_wait_done(struct mmc_request *mrq)
}
/**
+ * mmc_issue_hpi_cmd - start a hpi to interrupt background
+ * operations
+ * @card: MMC card need to interrupt
+ *
+ * start MMC_SEND_STATUS/MMC_STOP_TRANSMISSION to stop the
+ * background operations.
+ *
+ * return value:
+ * 0: successfully interrupt BKOPS
+ * -EINVAL: HPI command invalid
+ * -EIO: failed when interrupt BKOPS
+ */
+static int mmc_issue_hpi_cmd(struct mmc_card *card)
+{
+ struct mmc_command cmd;
+ unsigned int opcode;
+ unsigned int flags;
+ int err;
+
+ opcode = card->ext_csd.hpi_cmd;
+ if (opcode == MMC_STOP_TRANSMISSION)
+ flags = MMC_RSP_R1B | MMC_CMD_AC;
+ else if (opcode == MMC_SEND_STATUS)
+ flags = MMC_RSP_R1 | MMC_CMD_AC;
+ else
+ return -EINVAL;
+
+ memset(&cmd, 0, sizeof(struct mmc_command));
+ cmd.opcode = opcode;
+ cmd.arg = card->rca << 16 | 1;
+ cmd.flags = flags;
+ err = mmc_wait_for_cmd(card->host, &cmd, 0);
+ if (err || (cmd.resp[0] & R1_ERROR_RESPONSE)) {
+ printk(KERN_ERR "error %d requesting status %#x\n",
+ err, cmd.resp[0]);
+ /*
+ * abandon this BKOPS, let block layer handle
+ * this
+ */
+ return -EIO;
+ }
+ return 0;
+}
+
+/**
* mmc_wait_for_bkops- start a bkops check and wait for
* completion
* @card: MMC card need to check
@@ -224,9 +269,14 @@ retry:
if (card->ext_csd.hpi_en) {
/*
- * TODO
* HPI to interrupt BKOPS if supported
*/
+ err = mmc_issue_hpi_cmd(card);
+ if (err == -EINVAL) {
+ /* disable HPI feature */
+ card->ext_csd.hpi_en = 0;
+ goto retry;
+ }
} else {
memset(&cmd, 0, sizeof(struct mmc_command));
--
1.6.6.1
reply other threads:[~2010-12-03 12:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20101203121443.GE18655@intel.com \
--to=chuanxiao.dong@intel.com \
--cc=akpm@linux-foundation.org \
--cc=alan@linux.intel.com \
--cc=arjan@linux.intel.com \
--cc=cjb@laptop.org \
--cc=kmpark@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
/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