History

mmc: block: Issue a cache flush only when it's enabled

In command queueing mode, the cache isn't flushed via the mmc_flush_cache() function, but instead by issuing a CMDQ_TASK_MGMT (CMD48) with a FLUSH_CACHE opcode. In this path, we need to check if cache has been enabled, before deciding to flush the cache, along the lines of what's being done in mmc_flush_cache(). To fix this problem, let's add a new bus ops callback ->cache_enabled() and implement it for the mmc bus type. In this way, the mmc block device driver can call it to know whether cache flushing should be done.

Avri Altman committed 5 years ago

Commit 97fce121 parent 2f156714 files · +21 −3Browse files

Unified · Split

4 files
  1. drivers/mmc/core/block.c +4 −0
  2. drivers/mmc/core/core.h +9 −0
  3. drivers/mmc/core/mmc.c +7 −0
  4. drivers/mmc/core/mmc_ops.c +1 −3
drivers/mmc/core/block.c+4−0
@@ -2237,6 +2237,10 @@ enum mmc_issued mmc_blk_mq_issue_rq(struct mmc_queue *mq, struct request *req) · 2236 unmodified lines
22372237 case MMC_ISSUE_ASYNC:
22382238 switch (req_op(req)) {
22392239 case REQ_OP_FLUSH:
2240+ if (!mmc_cache_enabled(host)) {
2241+ blk_mq_end_request(req, BLK_STS_OK);
2242+ return MMC_REQ_FINISHED;
2243+ }
22402244 ret = mmc_blk_cqe_issue_flush(mq, req);
22412245 break;
22422246 case REQ_OP_READ:
drivers/mmc/core/core.h+9−0
@@ -29,6 +29,7 @@ struct mmc_bus_ops { · 28 unmodified lines
2929 int (*shutdown)(struct mmc_host *);
3030 int (*hw_reset)(struct mmc_host *);
3131 int (*sw_reset)(struct mmc_host *);
32+ bool (*cache_enabled)(struct mmc_host *);
3233 };
3334
3435 void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
@@ -163,4 +164,12 @@ static inline void mmc_post_req(struct mmc_host *host, struct mmc_request *mrq, · 128 unmodified lines
163164 host->ops->post_req(host, mrq, err);
164165 }
165166
167+static inline bool mmc_cache_enabled(struct mmc_host *host)
168+{
169+ if (host->bus_ops->cache_enabled)
170+ return host->bus_ops->cache_enabled(host);
171+
172+ return false;
173+}
174+
166175 #endif
drivers/mmc/core/mmc.c+7−0
@@ -2029,6 +2029,12 @@ static void mmc_detect(struct mmc_host *host) · 2028 unmodified lines
20292029 }
20302030 }
20312031
2032+static bool _mmc_cache_enabled(struct mmc_host *host)
2033+{
2034+ return host->card->ext_csd.cache_size > 0 &&
2035+ host->card->ext_csd.cache_ctrl & 1;
2036+}
2037+
20322038 static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
20332039 {
20342040 int err = 0;
@@ -2208,6 +2214,7 @@ static const struct mmc_bus_ops mmc_ops = { · 173 unmodified lines
22082214 .alive = mmc_alive,
22092215 .shutdown = mmc_shutdown,
22102216 .hw_reset = _mmc_hw_reset,
2217+ .cache_enabled = _mmc_cache_enabled,
22112218 };
22122219
22132220 /*
drivers/mmc/core/mmc_ops.c+1−3
@@ -968,9 +968,7 @@ int mmc_flush_cache(struct mmc_card *card) · 967 unmodified lines
968968 {
969969 int err = 0;
970970
971− if (mmc_card_mmc(card) &&
972− (card->ext_csd.cache_size > 0) &&
973− (card->ext_csd.cache_ctrl & 1)) {
971+ if (mmc_cache_enabled(card->host)) {
974972 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
975973 EXT_CSD_FLUSH_CACHE, 1,
976974 MMC_CACHE_FLUSH_TIMEOUT_MS);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t