Revert "Revert "mmc: queue: exclude asynchronous transfer for special request""

This reverts commit 95d90a5c6210e08a3ff81a0ab7d8b26f8f6ac6d9.

Change-Id: Ib925bb8d7dbcf0fc623db74a7a72e9bdf9e97166
Signed-off-by: Pavan Anamula <pavana@codeaurora.org>
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index cceb8d9..fd57f6e 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -24,6 +24,8 @@
 #define MMC_QUEUE_BOUNCESZ	65536
 
 
+#define MMC_REQ_SPECIAL_MASK	(REQ_DISCARD | REQ_FLUSH)
+
 /*
  * Based on benchmark tests the default num of requests to trigger the write
  * packing was determined, to keep the read latency as low as possible and
@@ -66,6 +68,7 @@
 	do {
 		struct mmc_queue_req *tmp;
 		struct request *req = NULL;
+		unsigned int cmd_flags = 0;
 
 		spin_lock_irq(q->queue_lock);
 		set_current_state(TASK_INTERRUPTIBLE);
@@ -75,6 +78,7 @@
 
 		if (req || mq->mqrq_prev->req) {
 			set_current_state(TASK_RUNNING);
+			cmd_flags = req ? req->cmd_flags : 0;
 			mq->issue_fn(mq, req);
 			if (test_bit(MMC_QUEUE_NEW_REQUEST, &mq->flags)) {
 				continue; /* fetch again */
@@ -95,7 +99,13 @@
 			/*
 			 * Current request becomes previous request
 			 * and vice versa.
+			 * In case of special requests, current request
+			 * has been finished. Do not assign it to previous
+			 * request.
 			 */
+			if (cmd_flags & MMC_REQ_SPECIAL_MASK)
+				mq->mqrq_cur->req = NULL;
+
 			mq->mqrq_prev->brq.mrq.data = NULL;
 			mq->mqrq_prev->req = NULL;
 			tmp = mq->mqrq_prev;