All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 4/4]use HPI to interrupt background operations
@ 2010-11-23  8:45 Chuanxiao Dong
  2010-11-24  4:07 ` Kyungmin Park
  0 siblings, 1 reply; 3+ messages in thread
From: Chuanxiao Dong @ 2010-11-23  8:45 UTC (permalink / raw)
  To: linux-mmc, cjb; +Cc: linux-kernel, alan, arjan, hang.yuan

>From 8d2cf8e4b890a3ef0c7b63da57b8b184ab64725d Mon Sep 17 00:00:00 2001
From: Chuanxiao Dong <chuanxiao.dong@intel.com>
Date: Tue, 23 Nov 2010 12:01:58 +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 implemented using HPI to interrupt BKOPS if eMMC card
supports HPI.

Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
---
 drivers/mmc/core/core.c |   51 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 6891169..644ce9d 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -202,6 +202,50 @@ 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;
+	err = mmc_wait_for_cmd(card->host, &cmd, 0);
+	if (err || (cmd.resp[0] & 0xFDF92000)) {
+		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 +268,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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 4/4]use HPI to interrupt background operations
  2010-11-23  8:45 [PATCH v1 4/4]use HPI to interrupt background operations Chuanxiao Dong
@ 2010-11-24  4:07 ` Kyungmin Park
  2010-11-24  4:33   ` Dong, Chuanxiao
  0 siblings, 1 reply; 3+ messages in thread
From: Kyungmin Park @ 2010-11-24  4:07 UTC (permalink / raw)
  To: Chuanxiao Dong; +Cc: linux-mmc, cjb, linux-kernel, alan, arjan, hang.yuan

On Tue, Nov 23, 2010 at 5:45 PM, Chuanxiao Dong
<chuanxiao.dong@intel.com> wrote:
> From 8d2cf8e4b890a3ef0c7b63da57b8b184ab64725d Mon Sep 17 00:00:00 2001
> From: Chuanxiao Dong <chuanxiao.dong@intel.com>
> Date: Tue, 23 Nov 2010 12:01:58 +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 implemented using HPI to interrupt BKOPS if eMMC card
> supports HPI.
>
> Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
> ---
>  drivers/mmc/core/core.c |   51 ++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 50 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 6891169..644ce9d 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -202,6 +202,50 @@ 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;
Maybe missing set the flags;
            cmd.flags = flags;

Thank you,
Kyungmin Park
> +       err = mmc_wait_for_cmd(card->host, &cmd, 0);
> +       if (err || (cmd.resp[0] & 0xFDF92000)) {
> +               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 +268,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
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH v1 4/4]use HPI to interrupt background operations
  2010-11-24  4:07 ` Kyungmin Park
@ 2010-11-24  4:33   ` Dong, Chuanxiao
  0 siblings, 0 replies; 3+ messages in thread
From: Dong, Chuanxiao @ 2010-11-24  4:33 UTC (permalink / raw)
  To: Kyungmin Park; +Cc: linux-mmc, cjb, linux-kernel, alan, arjan, Yuan, Hang

> > +       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;
> Maybe missing set the flags;
>             cmd.flags = flags;
> 
> Thank you,
> Kyungmin Park

Thank you Park, will fix these bad mistake in the next version submission.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-24  4:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-23  8:45 [PATCH v1 4/4]use HPI to interrupt background operations Chuanxiao Dong
2010-11-24  4:07 ` Kyungmin Park
2010-11-24  4:33   ` Dong, Chuanxiao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.