Skip to contentSkip to conversation

mmc: core: Support packed command for eMMC4.5 device

PATCH [email protected] 2 participants 4 messages Apr 26, 2012 – May 8, 2012 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

Hi Jeon,

Any update for splitting between the read and write packing? I also have a few more comments:

Quoted 1 line

+static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request

*req)

Review

Quoted 6 lines
(quoted diff) +6 -0
+{
+	struct request_queue *q = mq->queue;
+	struct mmc_card *card = mq->card;
+	struct request *cur = req, *next = NULL;
+	struct mmc_blk_data *md = mq->data;
+	bool en_rel_wr = card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN;

+ unsigned int req_sectors = 0, phys_segments = 0;

Quoted 25 lines
(quoted diff) +25 -0
+	unsigned int max_blk_count, max_phys_segs;
+	u8 put_back = 0;
+	u8 max_packed_rw = 0;
+	u8 reqs = 0;
+
+	mq->mqrq_cur->packed_num = MMC_PACKED_N_ZERO;
+
+	if (!(md->flags & MMC_BLK_CMD23) ||
+			!card->ext_csd.packed_event_en)
+		goto no_packed;
+
+	if ((rq_data_dir(cur) == READ) &&
+			(card->host->caps2 & MMC_CAP2_PACKED_RD))
+		max_packed_rw = card->ext_csd.max_packed_reads;
+	else if ((rq_data_dir(cur) == WRITE) &&
+			(card->host->caps2 & MMC_CAP2_PACKED_WR))
+		max_packed_rw = card->ext_csd.max_packed_writes;
+
+	if (max_packed_rw == 0)
+		goto no_packed;
+
+	if (mmc_req_rel_wr(cur) &&
+			(md->flags & MMC_BLK_REL_WR) &&
+			!en_rel_wr) {
+		goto no_packed;

Review

Quoted 10 lines
(quoted diff) +10 -0
+	}
+
+	max_blk_count = min(card->host->max_blk_count,
+			card->host->max_req_size >> 9);
+	if (unlikely(max_blk_count > 0xffff))
+		max_blk_count = 0xffff;
+
+	max_phys_segs = queue_max_segments(q);
+	req_sectors += blk_rq_sectors(cur);
+	phys_segments += req->nr_phys_segments;

It would be best to change req to cur. This is the only place you use req, in all other places you refer to cur.

Review static int mmc_blk_issue_rw_rq(struct mmc_queue

Quoted 1 line
(quoted diff) +0 -0
@@ -1291,10 +1657,42 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue

*mq, struct request *rqc)

Quoted 19 lines
(quoted diff) +14 -2
 			 * A block was successfully transferred.
 			 */
 			mmc_blk_reset_success(md, type);
-			spin_lock_irq(&md->lock);
-			ret = __blk_end_request(req, 0,
+
+			if (mq_rq->packed_cmd != MMC_PACKED_NONE) {
+				int idx = mq_rq->packed_fail_idx, i = 0;
+				ret = 0;
+				while (!list_empty(&mq_rq->packed_list)) {
+					prq = list_entry_rq(
+						mq_rq->packed_list.next);
+					if (idx == i) {
+						/* retry from error index */
+						mq_rq->packed_num -= idx;
+						mq_rq->req = prq;
+						ret = 1;
+						break;
+					}

Review static int mmc_blk_issue_rw_rq(struct mmc_queue · line 1683

Quoted 10 lines
(quoted diff) +10 -0
+					list_del_init(&prq->queuelist);
+					spin_lock_irq(&md->lock);
+					__blk_end_request(prq, 0,
+							blk_rq_bytes(prq));
+					spin_unlock_irq(&md->lock);
+					i++;
+				}
+				if (mq_rq->packed_num == MMC_PACKED_N_SINGLE) {
+					prq = list_entry_rq(
+						mq_rq->packed_list.next);

You already get the prq inside the while. There is no need to do it again.

Review static int mmc_blk_issue_rw_rq(struct mmc_queue

Quoted 1 line
(quoted diff) +0 -0
@@ -1329,6 +1727,8 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue

*mq,

Review static int mmc_blk_issue_rw_rq(struct mmc_queue · line 1732

Quoted 6 lines
(quoted diff) +2 -0
 struct request *rqc)
 				break;
 			if (err == -ENODEV)
 				goto cmd_abort;
+			if (mq_rq->packed_cmd != MMC_PACKED_NONE)
+				break;

This can cause an endless loop in case of MMC_BLK_DATA_ERR. The same packed command will be sent over and over again without a beaking point.

Thanks,
Maya Erez
Consultant for Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

#1 lore raw

Hi Maya,

Quoted 4 lines · Maya Erez

Hi Jeon,

Any update for splitting between the read and write packing?

I'll work soon.

Quoted 40 lines

I also have a few more comments:

Quoted 1 line

+static u8 mmc_blk_prep_packed_list(struct mmc_queue *mq, struct request

*req)

Quoted 6 lines
(quoted diff) +6 -0
+{
+	struct request_queue *q = mq->queue;
+	struct mmc_card *card = mq->card;
+	struct request *cur = req, *next = NULL;
+	struct mmc_blk_data *md = mq->data;
+	bool en_rel_wr = card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN;
(quoted diff) +1 -0
+	unsigned int req_sectors = 0, phys_segments = 0;
Quoted 29 lines
(quoted diff) +29 -0
+	unsigned int max_blk_count, max_phys_segs;
+	u8 put_back = 0;
+	u8 max_packed_rw = 0;
+	u8 reqs = 0;
+
+	mq->mqrq_cur->packed_num = MMC_PACKED_N_ZERO;
+
+	if (!(md->flags & MMC_BLK_CMD23) ||
+			!card->ext_csd.packed_event_en)
+		goto no_packed;
+
+	if ((rq_data_dir(cur) == READ) &&
+			(card->host->caps2 & MMC_CAP2_PACKED_RD))
+		max_packed_rw = card->ext_csd.max_packed_reads;
+	else if ((rq_data_dir(cur) == WRITE) &&
+			(card->host->caps2 & MMC_CAP2_PACKED_WR))
+		max_packed_rw = card->ext_csd.max_packed_writes;
+
+	if (max_packed_rw == 0)
+		goto no_packed;
+
+	if (mmc_req_rel_wr(cur) &&
+			(md->flags & MMC_BLK_REL_WR) &&
+			!en_rel_wr) {
+		goto no_packed;
+	}
+
+	max_blk_count = min(card->host->max_blk_count,
+			card->host->max_req_size >> 9);
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+	if (unlikely(max_blk_count > 0xffff))
+		max_blk_count = 0xffff;
+
+	max_phys_segs = queue_max_segments(q);
+	req_sectors += blk_rq_sectors(cur);
+	phys_segments += req->nr_phys_segments;

It would be best to change req to cur. This is the only place you use req, in all other places you refer to cur.

Good point.

Quoted 25 lines

Review static int mmc_blk_issue_rw_rq(struct mmc_queue

Quoted 2 lines
(quoted diff) +0 -0
@@ -1291,10 +1657,42 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue

*mq, struct request *rqc)

Quoted 22 lines
(quoted diff) +17 -2
 			 * A block was successfully transferred.
 			 */
 			mmc_blk_reset_success(md, type);
-			spin_lock_irq(&md->lock);
-			ret = __blk_end_request(req, 0,
+
+			if (mq_rq->packed_cmd != MMC_PACKED_NONE) {
+				int idx = mq_rq->packed_fail_idx, i = 0;
+				ret = 0;
+				while (!list_empty(&mq_rq->packed_list)) {
+					prq = list_entry_rq(
+						mq_rq->packed_list.next);
+					if (idx == i) {
+						/* retry from error index */
+						mq_rq->packed_num -= idx;
+						mq_rq->req = prq;
+						ret = 1;
+						break;
+					}
+					list_del_init(&prq->queuelist);
+					spin_lock_irq(&md->lock);
+					__blk_end_request(prq, 0,
Quoted 8 lines

Review static int mmc_blk_issue_rw_rq(struct mmc_queue · line 1683

Quoted 7 lines
(quoted diff) +7 -0
+							blk_rq_bytes(prq));
+					spin_unlock_irq(&md->lock);
+					i++;
+				}
+				if (mq_rq->packed_num == MMC_PACKED_N_SINGLE) {
+					prq = list_entry_rq(
+						mq_rq->packed_list.next);

You already get the prq inside the while. There is no need to do it again.

Right, but if while loop isn't taken, then prq can be used uninitialized. Though that case wouldn't happen actually, we don't want to see the compiling error.

Quoted 4 lines

Review static int mmc_blk_issue_rw_rq(struct mmc_queue

Quoted 3 lines
(quoted diff) +0 -0
@@ -1329,6 +1727,8 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue

*mq,

Quoted 8 lines

Review static int mmc_blk_issue_rw_rq(struct mmc_queue · line 1732

Quoted 6 lines
(quoted diff) +2 -0
 struct request *rqc)
 				break;
 			if (err == -ENODEV)
 				goto cmd_abort;
+			if (mq_rq->packed_cmd != MMC_PACKED_NONE)
+				break;

This can cause an endless loop in case of MMC_BLK_DATA_ERR. The same packed command will be sent over and over again without a beaking point.

Yes. It may be possible in case of twice MMC_BLK_DATA_ERR.

Thanks
Seungwon Jeon.

Quoted 14 lines

Thanks,
Maya Erez
Consultant for Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

--
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

#2 lore raw
Quoted 34 lines
Quoted 26 lines

Review static int mmc_blk_issue_rw_rq(struct

Quoted 1 line
(quoted diff) +0 -0
@@ -1291,10 +1657,42 @@ static int mmc_blk_issue_rw_rq(struct

mmc_queue
*mq, struct request *rqc)

Quoted 23 lines
(quoted diff) +18 -2
 			 * A block was successfully transferred.
 			 */
 			mmc_blk_reset_success(md, type);
-			spin_lock_irq(&md->lock);
-			ret = __blk_end_request(req, 0,
+
+			if (mq_rq->packed_cmd != MMC_PACKED_NONE) {
+				int idx = mq_rq->packed_fail_idx, i = 0;
+				ret = 0;
+				while (!list_empty(&mq_rq->packed_list)) {
+					prq = list_entry_rq(
+						mq_rq->packed_list.next);
+					if (idx == i) {
+						/* retry from error index */
+						mq_rq->packed_num -= idx;
+						mq_rq->req = prq;
+						ret = 1;
+						break;
+					}
+					list_del_init(&prq->queuelist);
+					spin_lock_irq(&md->lock);
+					__blk_end_request(prq, 0,
+							blk_rq_bytes(prq));
Quoted 8 lines

Review static int mmc_blk_issue_rw_rq(struct · line 1683

Quoted 6 lines
(quoted diff) +6 -0
+					spin_unlock_irq(&md->lock);
+					i++;
+				}
+				if (mq_rq->packed_num == MMC_PACKED_N_SINGLE) {
+					prq = list_entry_rq(
+						mq_rq->packed_list.next);

You already get the prq inside the while. There is no need to do it again.

Quoted 3 lines

Right, but if while loop isn't taken, then prq can be used uninitialized. Though that case wouldn't happen actually, we don't want to see the compiling error.

The loop must be taken since we are inside the case of packed commands so the list can't be empty.

If the compiler complained, you can set prq to be the first request before entering the loop instead of setting it again in the if that follows the loop. It will probably be more understood.
If you decide to leave it as is, I would also add the following to the if:
+ mq_rq->req = prq;
+ ret = 1;
Otherwise it seems like there could be a bug in cases where the loop is not taken (since prq is the only one that is set) and the code is less understood.

Thanks,
Maya Erez
Consultant for Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

#3 lore raw
Quoted 55 lines · Maya Erez

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of [email protected]
Sent: Thursday, May 03, 2012 3:35 AM
To: Seungwon Jeon
Cc: [email protected]; [email protected]; 'Chris Ball'; [email protected]
Subject: RE: [PATCH v5 2/2] mmc: core: Support packed command for eMMC4.5 device

Quoted 34 lines
Quoted 26 lines

Review static int mmc_blk_issue_rw_rq(struct

Quoted 1 line
(quoted diff) +0 -0
@@ -1291,10 +1657,42 @@ static int mmc_blk_issue_rw_rq(struct

mmc_queue
*mq, struct request *rqc)

Quoted 23 lines
(quoted diff) +18 -2
 			 * A block was successfully transferred.
 			 */
 			mmc_blk_reset_success(md, type);
-			spin_lock_irq(&md->lock);
-			ret = __blk_end_request(req, 0,
+
+			if (mq_rq->packed_cmd != MMC_PACKED_NONE) {
+				int idx = mq_rq->packed_fail_idx, i = 0;
+				ret = 0;
+				while (!list_empty(&mq_rq->packed_list)) {
+					prq = list_entry_rq(
+						mq_rq->packed_list.next);
+					if (idx == i) {
+						/* retry from error index */
+						mq_rq->packed_num -= idx;
+						mq_rq->req = prq;
+						ret = 1;
+						break;
+					}
+					list_del_init(&prq->queuelist);
+					spin_lock_irq(&md->lock);
+					__blk_end_request(prq, 0,
+							blk_rq_bytes(prq));
Quoted 8 lines

Review static int mmc_blk_issue_rw_rq(struct · line 1683

Quoted 6 lines
(quoted diff) +6 -0
+					spin_unlock_irq(&md->lock);
+					i++;
+				}
+				if (mq_rq->packed_num == MMC_PACKED_N_SINGLE) {
+					prq = list_entry_rq(
+						mq_rq->packed_list.next);

You already get the prq inside the while. There is no need to do it again.

Quoted 3 lines

Right, but if while loop isn't taken, then prq can be used uninitialized. Though that case wouldn't happen actually, we don't want to see the compiling error.

The loop must be taken since we are inside the case of packed commands so the list can't be empty.

If the compiler complained, you can set prq to be the first request before entering the loop instead of setting it again in the if that follows the loop. It will probably be more understood.
If you decide to leave it as is, I would also add the following to the if:

(quoted diff) +2 -0
+                                                mq_rq->req = prq;
+                                                ret = 1;
Quoted 3 lines

Otherwise it seems like there could be a bug in cases where the loop is not taken (since prq is the only one that is set) and the code is less understood.

I'll clarify this as you concern.
Thank you for your review.

Best regards,
Seungwon Jeon.

Quoted 11 lines

Thanks,
Maya Erez
Consultant for Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

--
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