hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/mmc/core/block.c
....@@ -256,6 +256,7 @@
256256 goto out_put;
257257 }
258258 req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_BOOT_WP;
259
+ req_to_mmc_queue_req(req)->drv_op_result = -EIO;
259260 blk_execute_rq(mq->queue, NULL, req, 0);
260261 ret = req_to_mmc_queue_req(req)->drv_op_result;
261262 blk_put_request(req);
....@@ -415,7 +416,7 @@
415416 static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
416417 u32 *resp_errs)
417418 {
418
- unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
419
+ unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms > 2000 ? 2000 : timeout_ms);
419420 int err = 0;
420421 u32 status;
421422
....@@ -649,6 +650,7 @@
649650 idatas[0] = idata;
650651 req_to_mmc_queue_req(req)->drv_op =
651652 rpmb ? MMC_DRV_OP_IOCTL_RPMB : MMC_DRV_OP_IOCTL;
653
+ req_to_mmc_queue_req(req)->drv_op_result = -EIO;
652654 req_to_mmc_queue_req(req)->drv_op_data = idatas;
653655 req_to_mmc_queue_req(req)->ioc_count = 1;
654656 blk_execute_rq(mq->queue, NULL, req, 0);
....@@ -718,6 +720,7 @@
718720 }
719721 req_to_mmc_queue_req(req)->drv_op =
720722 rpmb ? MMC_DRV_OP_IOCTL_RPMB : MMC_DRV_OP_IOCTL;
723
+ req_to_mmc_queue_req(req)->drv_op_result = -EIO;
721724 req_to_mmc_queue_req(req)->drv_op_data = idata;
722725 req_to_mmc_queue_req(req)->ioc_count = num_of_cmds;
723726 blk_execute_rq(mq->queue, NULL, req, 0);
....@@ -1781,8 +1784,15 @@
17811784 * bytes transferred to zero in that case.
17821785 */
17831786 err = __mmc_send_status(card, &status, 0);
1784
- if (err || mmc_blk_status_error(req, status))
1787
+ if (err || mmc_blk_status_error(req, status)) {
17851788 brq->data.bytes_xfered = 0;
1789
+ if (mmc_card_sd(card) && !mmc_card_removed(card)) {
1790
+ mmc_blk_reset_success(mq->blkdata, type);
1791
+ if (!mmc_blk_reset(md, card->host, type))
1792
+ return;
1793
+ pr_err("%s: pre recovery failed!\n", req->rq_disk->disk_name);
1794
+ }
1795
+ }
17861796
17871797 mmc_retune_release(card->host);
17881798
....@@ -1996,14 +2006,14 @@
19962006 mmc_blk_urgent_bkops(mq, mqrq);
19972007 }
19982008
1999
-static void mmc_blk_mq_dec_in_flight(struct mmc_queue *mq, struct request *req)
2009
+static void mmc_blk_mq_dec_in_flight(struct mmc_queue *mq, enum mmc_issue_type issue_type)
20002010 {
20012011 unsigned long flags;
20022012 bool put_card;
20032013
20042014 spin_lock_irqsave(&mq->lock, flags);
20052015
2006
- mq->in_flight[mmc_issue_type(mq, req)] -= 1;
2016
+ mq->in_flight[issue_type] -= 1;
20072017
20082018 put_card = (mmc_tot_in_flight(mq) == 0);
20092019
....@@ -2015,6 +2025,7 @@
20152025
20162026 static void mmc_blk_mq_post_req(struct mmc_queue *mq, struct request *req)
20172027 {
2028
+ enum mmc_issue_type issue_type = mmc_issue_type(mq, req);
20182029 struct mmc_queue_req *mqrq = req_to_mmc_queue_req(req);
20192030 struct mmc_request *mrq = &mqrq->brq.mrq;
20202031 struct mmc_host *host = mq->card->host;
....@@ -2030,7 +2041,7 @@
20302041 else if (likely(!blk_should_fake_timeout(req->q)))
20312042 blk_mq_complete_request(req);
20322043
2033
- mmc_blk_mq_dec_in_flight(mq, req);
2044
+ mmc_blk_mq_dec_in_flight(mq, issue_type);
20342045 }
20352046
20362047 void mmc_blk_mq_recovery(struct mmc_queue *mq)
....@@ -2768,6 +2779,7 @@
27682779 if (IS_ERR(req))
27692780 return PTR_ERR(req);
27702781 req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_CARD_STATUS;
2782
+ req_to_mmc_queue_req(req)->drv_op_result = -EIO;
27712783 blk_execute_rq(mq->queue, NULL, req, 0);
27722784 ret = req_to_mmc_queue_req(req)->drv_op_result;
27732785 if (ret >= 0) {
....@@ -2806,6 +2818,7 @@
28062818 goto out_free;
28072819 }
28082820 req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_EXT_CSD;
2821
+ req_to_mmc_queue_req(req)->drv_op_result = -EIO;
28092822 req_to_mmc_queue_req(req)->drv_op_data = &ext_csd;
28102823 blk_execute_rq(mq->queue, NULL, req, 0);
28112824 err = req_to_mmc_queue_req(req)->drv_op_result;