mirror of https://lore.kernel.org/lkml/
 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 16/16] mmc: omap_hsmmc: Implement abort_req host_ops
Date: Thu, 3 May 2012 19:53:15 +0530	[thread overview]
Message-ID: <1336054995-22988-17-git-send-email-svenkatr@ti.com> (raw)
In-Reply-To: <1336054995-22988-1-git-send-email-svenkatr@ti.com>

Provide the abort_req implementation for omap_hsmmc host.

When invoked, the host controller should stop the transfer
and end the ongoing request as early as possible.

If the aborted command is a data transfer command, dma setup is
aborted and a STOP command is issued. The transfer state is
marked as an error (except when the command has almost completed
while receiving the abort request, in which case finish the command
normally).

Signed-off-by: Venkatraman S <svenkatr@ti.com>
---
 drivers/mmc/host/omap_hsmmc.c |   55 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 51 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index d15b149..a4da478 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -177,6 +177,7 @@ struct omap_hsmmc_host {
 	int			reqs_blocked;
 	int			use_reg;
 	int			req_in_progress;
+	int			abort_in_progress;
 	unsigned int		flags;
 	struct omap_hsmmc_next	next_data;
 
@@ -982,6 +983,7 @@ static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host,
 static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
 {
 	struct mmc_data *data;
+	int err = 0;
 	int end_cmd = 0, end_trans = 0;
 
 	if (!host->req_in_progress) {
@@ -993,6 +995,11 @@ static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
 		return;
 	}
 
+	if (host->abort_in_progress) {
+		end_trans = 1;
+		end_cmd = 1;
+	}
+
 	data = host->data;
 	dev_dbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status);
 
@@ -1021,7 +1028,7 @@ static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
 		if ((status & DATA_TIMEOUT) ||
 			(status & DATA_CRC)) {
 			if (host->data || host->response_busy) {
-				int err = (status & DATA_TIMEOUT) ?
+				err = (status & DATA_TIMEOUT) ?
 						-ETIMEDOUT : -EILSEQ;
 
 				if (host->data)
@@ -1045,10 +1052,13 @@ static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
 
 	OMAP_HSMMC_WRITE(host->base, STAT, status);
 
-	if (end_cmd || ((status & CC) && host->cmd))
+	if ((end_cmd || (status & CC)) && host->cmd)
 		omap_hsmmc_cmd_done(host, host->cmd);
-	if ((end_trans || (status & TC)) && host->mrq)
+	if ((end_trans || (status & TC)) && host->mrq) {
+		if (data)
+			data->error = err;
 		omap_hsmmc_xfer_done(host, data);
+	}
 }
 
 /*
@@ -1257,7 +1267,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data)
 	}
 
 	spin_lock_irqsave(&host->irq_lock, flags);
-	if (host->dma_ch < 0) {
+	if (host->dma_ch < 0 || host->abort_in_progress) {
 		spin_unlock_irqrestore(&host->irq_lock, flags);
 		return;
 	}
@@ -1478,6 +1488,40 @@ static void omap_hsmmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq,
 			mrq->data->host_cookie = 0;
 }
 
+static int omap_hsmmc_abort_req(struct mmc_host *mmc, struct mmc_request *req)
+{
+	struct omap_hsmmc_host *host = mmc_priv(mmc);
+	unsigned long flags;
+
+	if (!host->req_in_progress) {
+		dev_dbg(mmc_dev(host->mmc), "No request to abort\n");
+		return -EINVAL;
+	}
+	if (req && req != host->mrq) {
+		dev_dbg(mmc_dev(host->mmc), "Non matching abort request\n");
+		return -EINVAL;
+	}
+	spin_lock_irqsave(&host->irq_lock, flags);
+	host->abort_in_progress = 1;
+	omap_hsmmc_disable_irq(host);
+	spin_unlock_irqrestore(&host->irq_lock, flags);
+
+	host->response_busy = 0;
+
+	if (host->data) {
+		struct mmc_data *dat = host->data;
+		omap_hsmmc_dma_cleanup(host, -EIO);
+		dev_dbg(mmc_dev(host->mmc), "Aborting Transfer\n");
+		omap_hsmmc_xfer_done(host, dat);
+	} else if (host->cmd) {
+		dev_dbg(mmc_dev(host->mmc), "Aborting Command\n");
+		omap_hsmmc_cmd_done(host, host->cmd);
+	}
+
+	dev_dbg(mmc_dev(host->mmc), "Request %pK aborted\n", req);
+	return 0;
+
+}
 /*
  * Request function. for read/write operation
  */
@@ -1488,6 +1532,8 @@ static void omap_hsmmc_request(struct mmc_host *mmc, struct mmc_request *req)
 
 	BUG_ON(host->req_in_progress);
 	BUG_ON(host->dma_ch != -1);
+	host->abort_in_progress = 0;
+
 	if (host->protect_card) {
 		if (host->reqs_blocked < 3) {
 			/*
@@ -1664,6 +1710,7 @@ static const struct mmc_host_ops omap_hsmmc_ops = {
 	.disable = omap_hsmmc_disable_fclk,
 	.post_req = omap_hsmmc_post_req,
 	.pre_req = omap_hsmmc_pre_req,
+	.abort_req = omap_hsmmc_abort_req,
 	.request = omap_hsmmc_request,
 	.set_ios = omap_hsmmc_set_ios,
 	.get_cd = omap_hsmmc_get_cd,
-- 
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 ` [PATCH v2 15/16] mmc: Update preempted request with CORRECTLY_PRG_SECTORS_NUM info Venkatraman S
2012-05-03 14:23 ` Venkatraman S [this message]
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-17-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

all inboxes | Powered by JetHome®