Skip to contentSkip to conversation

mmc: queue: amend buffer swap for non-blocking transfer

PATCH Seungwon Jeon 4 participants 4 messages Sep 28, 2012 – Oct 23, 2012 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

In case both 'req' and 'mq->mqrq_prev->req' are null, there is no request to be processed. That means there is no need to switch buffer. Switching buffer is required only after finishing 'issue_fn'.

---
 drivers/mmc/card/queue.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
drivers/mmc/card/queue.c +10 -7
index e360a97..fadf52e 100644
@@ -68,6 +68,16 @@ static int mmc_queue_thread(void *d)
 		if (req || mq->mqrq_prev->req) {
 			set_current_state(TASK_RUNNING);
 			mq->issue_fn(mq, req);
+
+			/*
+			 * Current request becomes previous request
+			 * and vice versa.
+			 */
+			mq->mqrq_prev->brq.mrq.data = NULL;
+			mq->mqrq_prev->req = NULL;
+			tmp = mq->mqrq_prev;
+			mq->mqrq_prev = mq->mqrq_cur;
+			mq->mqrq_cur = tmp;
 		} else {
 			if (kthread_should_stop()) {
 				set_current_state(TASK_RUNNING);
@@ -77,13 +87,6 @@ static int mmc_queue_thread(void *d)
 			schedule();
 			down(&mq->thread_sem);
 		}
-
-		/* Current request becomes previous request and vice versa. */
-		mq->mqrq_prev->brq.mrq.data = NULL;
-		mq->mqrq_prev->req = NULL;
-		tmp = mq->mqrq_prev;
-		mq->mqrq_prev = mq->mqrq_cur;
-		mq->mqrq_cur = tmp;
 	} while (1);
 	up(&mq->thread_sem);
 
Signature · 1 line
1.7.0.4
Reviewed-by
#1 lore raw

Hi,

This is really a micro optimization. Still the patch looks correct. CUR and PREV will have the same values before and after this patch. Before this patch, NULL was assigned to NULL which is not necessary of course.

Thanks,
Per

Quoted 52 lines · Seungwon Jeon

In case both 'req' and 'mq->mqrq_prev->req' are null, there is no request to be processed. That means there is no need to switch buffer. Switching buffer is required only after finishing 'issue_fn'.

---
 drivers/mmc/card/queue.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
drivers/mmc/card/queue.c +10 -8
index e360a97..fadf52e 100644
@@ -68,6 +68,16 @@ static int mmc_queue_thread(void *d)
                if (req || mq->mqrq_prev->req) {
                        set_current_state(TASK_RUNNING);
                        mq->issue_fn(mq, req);
+
+                       /*
+                        * Current request becomes previous request
+                        * and vice versa.
+                        */
+                       mq->mqrq_prev->brq.mrq.data = NULL;
+                       mq->mqrq_prev->req = NULL;
+                       tmp = mq->mqrq_prev;
+                       mq->mqrq_prev = mq->mqrq_cur;
+                       mq->mqrq_cur = tmp;
                } else {
                        if (kthread_should_stop()) {
                                set_current_state(TASK_RUNNING);
@@ -77,13 +87,6 @@ static int mmc_queue_thread(void *d)
                        schedule();
                        down(&mq->thread_sem);
                }
-
-               /* Current request becomes previous request and vice versa. */
-               mq->mqrq_prev->brq.mrq.data = NULL;
-               mq->mqrq_prev->req = NULL;
-               tmp = mq->mqrq_prev;
-               mq->mqrq_prev = mq->mqrq_cur;
-               mq->mqrq_cur = tmp;
        } while (1);
        up(&mq->thread_sem);
 
--

1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Tested-by
#2 lore raw

Hi,

//Johan

2012/9/28 Per Forlin <[email protected]>:

Quoted 68 lines

Hi,

This is really a micro optimization. Still the patch looks correct. CUR and PREV will have the same values before and after this patch. Before this patch, NULL was assigned to NULL which is not necessary of course.

Thanks,
Per

Quoted 48 lines · Seungwon Jeon

In case both 'req' and 'mq->mqrq_prev->req' are null, there is no request to be processed. That means there is no need to switch buffer. Switching buffer is required only after finishing 'issue_fn'.

---
 drivers/mmc/card/queue.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
drivers/mmc/card/queue.c +10 -8
index e360a97..fadf52e 100644
@@ -68,6 +68,16 @@ static int mmc_queue_thread(void *d)
                if (req || mq->mqrq_prev->req) {
                        set_current_state(TASK_RUNNING);
                        mq->issue_fn(mq, req);
+
+                       /*
+                        * Current request becomes previous request
+                        * and vice versa.
+                        */
+                       mq->mqrq_prev->brq.mrq.data = NULL;
+                       mq->mqrq_prev->req = NULL;
+                       tmp = mq->mqrq_prev;
+                       mq->mqrq_prev = mq->mqrq_cur;
+                       mq->mqrq_cur = tmp;
                } else {
                        if (kthread_should_stop()) {
                                set_current_state(TASK_RUNNING);
@@ -77,13 +87,6 @@ static int mmc_queue_thread(void *d)
                        schedule();
                        down(&mq->thread_sem);
                }
-
-               /* Current request becomes previous request and vice versa. */
-               mq->mqrq_prev->brq.mrq.data = NULL;
-               mq->mqrq_prev->req = NULL;
-               tmp = mq->mqrq_prev;
-               mq->mqrq_prev = mq->mqrq_cur;
-               mq->mqrq_cur = tmp;
        } while (1);
        up(&mq->thread_sem);
 
--

1.7.0.4

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Seungwon Jeon

Hi,

Quoted 33 lines · Seungwon Jeon

In case both 'req' and 'mq->mqrq_prev->req' are null, there is no request to be processed. That means there is no need to switch buffer. Switching buffer is required only after finishing 'issue_fn'.

---
 drivers/mmc/card/queue.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
drivers/mmc/card/queue.c +10 -0
index e360a97..fadf52e 100644
@@ -68,6 +68,16 @@ static int mmc_queue_thread(void *d)
 		if (req || mq->mqrq_prev->req) {
 			set_current_state(TASK_RUNNING);
 			mq->issue_fn(mq, req);
+
+			/*
+			 * Current request becomes previous request
+			 * and vice versa.
+			 */
+			mq->mqrq_prev->brq.mrq.data = NULL;
+			mq->mqrq_prev->req = NULL;
+			tmp = mq->mqrq_prev;
+			mq->mqrq_prev = mq->mqrq_cur;
+			mq->mqrq_cur = tmp;
 		} else {
 			if (kthread_should_stop()) {
 				set_current_state(TASK_RUNNING);
@@ -77,13 +87,6 @@ static int mmc_queue_thread(void *d)
 			schedule();
 			down(&mq->thread_sem);

drivers/mmc/card/queue.c static int mmc_queue_thread(void *d) · line 91

Quoted 10 lines
drivers/mmc/card/queue.c +0 -7
 		}
-
-		/* Current request becomes previous request and vice versa. */
-		mq->mqrq_prev->brq.mrq.data = NULL;
-		mq->mqrq_prev->req = NULL;
-		tmp = mq->mqrq_prev;
-		mq->mqrq_prev = mq->mqrq_cur;
-		mq->mqrq_cur = tmp;
 	} while (1);
 	up(&mq->thread_sem);

Thanks, pushed to mmc-next for 3.8.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child