Skip to contentSkip to conversation

mmc: block: Requeue on block size restrictions

PATCH In review Christian Löhle 2 participants 2 messages Oct 26, 2022 – Nov 18, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 mmc: block: Requeue on block size restrictions

The block layer does not conform to all our sector count restrictions, so requeue in case we had to modify the number of blocks sent instead of going through the normal completion.

Note that the normal completion used before does not lead to a bug, this change is just the nicer thing to do.
An example of such a restriction is max_blk_count = 1 and 512 blksz, but the block layer continues to use requests of size PAGE_SIZE.

---
 drivers/mmc/core/block.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mmc/core/block.c +9 -3
index 54cd009aee50..c434d3964880 100644
@@ -1519,8 +1519,10 @@ static void mmc_blk_cqe_req_done(struct mmc_request *mrq)
 	/*
 	 * Block layer timeouts race with completions which means the normal
 	 * completion path cannot be used during recovery.
+	 * Also do not use it if we had to modify the block count to satisfy
+	 * host controller needs.
 	 */
-	if (mq->in_recovery)
+	if (mq->in_recovery || mrq->data->blocks != blk_rq_sectors(req))
 		mmc_blk_cqe_complete_rq(mq, req);
 	else if (likely(!blk_should_fake_timeout(req->q)))
 		blk_mq_complete_request(req);
@@ -2051,8 +2053,10 @@ static void mmc_blk_hsq_req_done(struct mmc_request *mrq)
 	/*
 	 * Block layer timeouts race with completions which means the normal
 	 * completion path cannot be used during recovery.
+	 * Also do not use it if we had to modify the block count to satisfy
+	 * host controller needs.
 	 */
-	if (mq->in_recovery)
+	if (mq->in_recovery || mrq->data->blocks != blk_rq_sectors(req))
 		mmc_blk_cqe_complete_rq(mq, req);
 	else if (likely(!blk_should_fake_timeout(req->q)))
 		blk_mq_complete_request(req);
@@ -2115,8 +2119,10 @@ static void mmc_blk_mq_post_req(struct mmc_queue *mq, struct request *req,
 	/*
 	 * Block layer timeouts race with completions which means the normal
 	 * completion path cannot be used during recovery.
+	 * Also do not use it if we had to modify the block count to satisfy
+	 * host controller needs.
 	 */
-	if (mq->in_recovery) {
+	if (mq->in_recovery || mrq->data->blocks != blk_rq_sectors(req)) {
 		mmc_blk_mq_complete_rq(mq, req);
 	} else if (likely(!blk_should_fake_timeout(req->q))) {
 		if (can_sleep)
Signature · 5 lines
2.37.3

Hyperstone GmbH | Reichenaustr. 39a  | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782
#1 lore raw
Quoted 6 lines · Christian Löhle

The block layer does not conform to all our sector count restrictions, so requeue in case we had to modify the number of blocks sent instead of going through the normal completion.

Note that the normal completion used before does not lead to a bug, this change is just the nicer thing to do.

Can you elaborate on why it is "nicer"?

Quoted 48 lines

An example of such a restriction is max_blk_count = 1 and 512 blksz, but the block layer continues to use requests of size PAGE_SIZE.

---
 drivers/mmc/core/block.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mmc/core/block.c +9 -3
index 54cd009aee50..c434d3964880 100644
@@ -1519,8 +1519,10 @@ static void mmc_blk_cqe_req_done(struct mmc_request *mrq)
 	/*
 	 * Block layer timeouts race with completions which means the normal
 	 * completion path cannot be used during recovery.
+	 * Also do not use it if we had to modify the block count to satisfy
+	 * host controller needs.
 	 */
-	if (mq->in_recovery)
+	if (mq->in_recovery || mrq->data->blocks != blk_rq_sectors(req))
 		mmc_blk_cqe_complete_rq(mq, req);
 	else if (likely(!blk_should_fake_timeout(req->q)))
 		blk_mq_complete_request(req);
@@ -2051,8 +2053,10 @@ static void mmc_blk_hsq_req_done(struct mmc_request *mrq)
 	/*
 	 * Block layer timeouts race with completions which means the normal
 	 * completion path cannot be used during recovery.
+	 * Also do not use it if we had to modify the block count to satisfy
+	 * host controller needs.
 	 */
-	if (mq->in_recovery)
+	if (mq->in_recovery || mrq->data->blocks != blk_rq_sectors(req))
 		mmc_blk_cqe_complete_rq(mq, req);
 	else if (likely(!blk_should_fake_timeout(req->q)))
 		blk_mq_complete_request(req);
@@ -2115,8 +2119,10 @@ static void mmc_blk_mq_post_req(struct mmc_queue *mq, struct request *req,
 	/*
 	 * Block layer timeouts race with completions which means the normal
 	 * completion path cannot be used during recovery.
+	 * Also do not use it if we had to modify the block count to satisfy
+	 * host controller needs.
 	 */
-	if (mq->in_recovery) {
+	if (mq->in_recovery || mrq->data->blocks != blk_rq_sectors(req)) {
 		mmc_blk_mq_complete_rq(mq, req);
 	} else if (likely(!blk_should_fake_timeout(req->q))) {
 		if (can_sleep)