4f1d02c74daca60ff2fc1196daa8dad874044099
[openwrt/staging/wigyori.git] /
1 From 19682239a60c1b53cad8319eaeb58e71d4213cee Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.com>
3 Date: Mon, 15 Jul 2024 13:38:38 +0100
4 Subject: [PATCH 1168/1215] fixup: mmc: restrict posted write counts for SD
5 cards in CQ mode
6
7 Leaving card->max_posted_writes unintialised was a bad thing to do.
8
9 Also, cqe_enable is 1 if hsq is enabled as hsq substitutes the cqhci
10 implementation with its own.
11
12 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
13 ---
14 drivers/mmc/core/mmc.c | 1 +
15 drivers/mmc/core/queue.c | 2 +-
16 drivers/mmc/core/sd.c | 14 ++++++++------
17 3 files changed, 10 insertions(+), 7 deletions(-)
18
19 --- a/drivers/mmc/core/mmc.c
20 +++ b/drivers/mmc/core/mmc.c
21 @@ -1663,6 +1663,7 @@ static int mmc_init_card(struct mmc_host
22 card->ocr = ocr;
23 card->type = MMC_TYPE_MMC;
24 card->rca = 1;
25 + card->max_posted_writes = 1;
26 memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
27 }
28
29 --- a/drivers/mmc/core/queue.c
30 +++ b/drivers/mmc/core/queue.c
31 @@ -268,7 +268,7 @@ static blk_status_t mmc_mq_queue_rq(stru
32 spin_unlock_irq(&mq->lock);
33 return BLK_STS_RESOURCE;
34 }
35 - if (host->cqe_enabled && req_op(req) == REQ_OP_WRITE &&
36 + if (!host->hsq_enabled && host->cqe_enabled && req_op(req) == REQ_OP_WRITE &&
37 mq->pending_writes >= card->max_posted_writes) {
38 spin_unlock_irq(&mq->lock);
39 return BLK_STS_RESOURCE;
40 --- a/drivers/mmc/core/sd.c
41 +++ b/drivers/mmc/core/sd.c
42 @@ -1105,13 +1105,14 @@ static int sd_parse_ext_reg_perf(struct
43 mmc_hostname(card->host),
44 card->ext_csd.cmdq_depth);
45 /*
46 - * If CQ is enabled, there is a contract between host and card such that VDD will
47 - * be maintained and removed only if a power off notification is provided.
48 - * An SD card in an accessible slot means surprise removal is a possibility.
49 - * As a middle ground, limit max posted writes to 1 unless the card is "hardwired".
50 + * If CQ is enabled, there is a contract between host and card such that
51 + * VDD will be maintained and removed only if a power off notification
52 + * is provided. An SD card in an accessible slot means surprise removal
53 + * is a possibility. As a middle ground, keep the default maximum of 1
54 + * posted write unless the card is "hardwired".
55 */
56 - if (mmc_card_is_removable(card->host))
57 - card->max_posted_writes = 1;
58 + if (!mmc_card_is_removable(card->host))
59 + card->max_posted_writes = card->ext_csd.cmdq_depth;
60 }
61
62 card->ext_perf.fno = fno;
63 @@ -1383,6 +1384,7 @@ retry:
64
65 card->ocr = ocr;
66 card->type = MMC_TYPE_SD;
67 + card->max_posted_writes = 1;
68 memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
69 }
70