Skip to content

Commit 3977a3f

Browse files
committed
Merge tag 'mmc-v5.17-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: "MMC core: - Restore (mostly) the busy polling for MMC_SEND_OP_COND MMC host: - meson-gx: Fix DMA usage of meson_mmc_post_req()" * tag 'mmc-v5.17-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: core: Restore (almost) the busy polling for MMC_SEND_OP_COND mmc: meson: Fix usage of meson_mmc_post_req()
2 parents 93ce935 + 1760fdb commit 3977a3f

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

drivers/mmc/core/block.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ static int mmc_blk_card_busy(struct mmc_card *card, struct request *req)
19081908

19091909
cb_data.card = card;
19101910
cb_data.status = 0;
1911-
err = __mmc_poll_for_busy(card->host, MMC_BLK_TIMEOUT_MS,
1911+
err = __mmc_poll_for_busy(card->host, 0, MMC_BLK_TIMEOUT_MS,
19121912
&mmc_blk_busy_cb, &cb_data);
19131913

19141914
/*

drivers/mmc/core/mmc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ static int mmc_sleep(struct mmc_host *host)
19621962
goto out_release;
19631963
}
19641964

1965-
err = __mmc_poll_for_busy(host, timeout_ms, &mmc_sleep_busy_cb, host);
1965+
err = __mmc_poll_for_busy(host, 0, timeout_ms, &mmc_sleep_busy_cb, host);
19661966

19671967
out_release:
19681968
mmc_retune_release(host);

drivers/mmc/core/mmc_ops.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#define MMC_BKOPS_TIMEOUT_MS (120 * 1000) /* 120s */
2323
#define MMC_SANITIZE_TIMEOUT_MS (240 * 1000) /* 240s */
24+
#define MMC_OP_COND_PERIOD_US (1 * 1000) /* 1ms */
25+
#define MMC_OP_COND_TIMEOUT_MS 1000 /* 1s */
2426

2527
static const u8 tuning_blk_pattern_4bit[] = {
2628
0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc,
@@ -232,7 +234,9 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
232234
cmd.arg = mmc_host_is_spi(host) ? 0 : ocr;
233235
cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR;
234236

235-
err = __mmc_poll_for_busy(host, 1000, &__mmc_send_op_cond_cb, &cb_data);
237+
err = __mmc_poll_for_busy(host, MMC_OP_COND_PERIOD_US,
238+
MMC_OP_COND_TIMEOUT_MS,
239+
&__mmc_send_op_cond_cb, &cb_data);
236240
if (err)
237241
return err;
238242

@@ -495,13 +499,14 @@ static int mmc_busy_cb(void *cb_data, bool *busy)
495499
return 0;
496500
}
497501

498-
int __mmc_poll_for_busy(struct mmc_host *host, unsigned int timeout_ms,
502+
int __mmc_poll_for_busy(struct mmc_host *host, unsigned int period_us,
503+
unsigned int timeout_ms,
499504
int (*busy_cb)(void *cb_data, bool *busy),
500505
void *cb_data)
501506
{
502507
int err;
503508
unsigned long timeout;
504-
unsigned int udelay = 32, udelay_max = 32768;
509+
unsigned int udelay = period_us ? period_us : 32, udelay_max = 32768;
505510
bool expired = false;
506511
bool busy = false;
507512

@@ -546,7 +551,7 @@ int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
546551
cb_data.retry_crc_err = retry_crc_err;
547552
cb_data.busy_cmd = busy_cmd;
548553

549-
return __mmc_poll_for_busy(host, timeout_ms, &mmc_busy_cb, &cb_data);
554+
return __mmc_poll_for_busy(host, 0, timeout_ms, &mmc_busy_cb, &cb_data);
550555
}
551556
EXPORT_SYMBOL_GPL(mmc_poll_for_busy);
552557

drivers/mmc/core/mmc_ops.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ int mmc_can_ext_csd(struct mmc_card *card);
4141
int mmc_switch_status(struct mmc_card *card, bool crc_err_fatal);
4242
bool mmc_prepare_busy_cmd(struct mmc_host *host, struct mmc_command *cmd,
4343
unsigned int timeout_ms);
44-
int __mmc_poll_for_busy(struct mmc_host *host, unsigned int timeout_ms,
44+
int __mmc_poll_for_busy(struct mmc_host *host, unsigned int period_us,
45+
unsigned int timeout_ms,
4546
int (*busy_cb)(void *cb_data, bool *busy),
4647
void *cb_data);
4748
int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,

drivers/mmc/core/sd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ static int sd_poweroff_notify(struct mmc_card *card)
16721672

16731673
cb_data.card = card;
16741674
cb_data.reg_buf = reg_buf;
1675-
err = __mmc_poll_for_busy(card->host, SD_POWEROFF_NOTIFY_TIMEOUT_MS,
1675+
err = __mmc_poll_for_busy(card->host, 0, SD_POWEROFF_NOTIFY_TIMEOUT_MS,
16761676
&sd_busy_poweroff_notify_cb, &cb_data);
16771677

16781678
out:

drivers/mmc/host/meson-gx-mmc.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ struct meson_host {
173173
int irq;
174174

175175
bool vqmmc_enabled;
176+
bool needs_pre_post_req;
177+
176178
};
177179

178180
#define CMD_CFG_LENGTH_MASK GENMASK(8, 0)
@@ -663,6 +665,8 @@ static void meson_mmc_request_done(struct mmc_host *mmc,
663665
struct meson_host *host = mmc_priv(mmc);
664666

665667
host->cmd = NULL;
668+
if (host->needs_pre_post_req)
669+
meson_mmc_post_req(mmc, mrq, 0);
666670
mmc_request_done(host->mmc, mrq);
667671
}
668672

@@ -880,7 +884,7 @@ static int meson_mmc_validate_dram_access(struct mmc_host *mmc, struct mmc_data
880884
static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
881885
{
882886
struct meson_host *host = mmc_priv(mmc);
883-
bool needs_pre_post_req = mrq->data &&
887+
host->needs_pre_post_req = mrq->data &&
884888
!(mrq->data->host_cookie & SD_EMMC_PRE_REQ_DONE);
885889

886890
/*
@@ -896,22 +900,19 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
896900
}
897901
}
898902

899-
if (needs_pre_post_req) {
903+
if (host->needs_pre_post_req) {
900904
meson_mmc_get_transfer_mode(mmc, mrq);
901905
if (!meson_mmc_desc_chain_mode(mrq->data))
902-
needs_pre_post_req = false;
906+
host->needs_pre_post_req = false;
903907
}
904908

905-
if (needs_pre_post_req)
909+
if (host->needs_pre_post_req)
906910
meson_mmc_pre_req(mmc, mrq);
907911

908912
/* Stop execution */
909913
writel(0, host->regs + SD_EMMC_START);
910914

911915
meson_mmc_start_cmd(mmc, mrq->sbc ?: mrq->cmd);
912-
913-
if (needs_pre_post_req)
914-
meson_mmc_post_req(mmc, mrq, 0);
915916
}
916917

917918
static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd)

0 commit comments

Comments
 (0)