Skip to content

Commit 09443a1

Browse files
committed
Merge tag 'mmc-v6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: "MMC core: - Fix CQE error recovery path MMC host: - cqhci: Fix CQE error recovery path - sdhci-pci-gli: Fix initialization of LPM - sdhci-sprd: Fix enabling/disabling of the vqmmc regulator" * tag 'mmc-v6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: sdhci-sprd: Fix vqmmc not shutting down after the card was pulled mmc: sdhci-pci-gli: Disable LPM during initialization mmc: cqhci: Fix task clearing in CQE error recovery mmc: cqhci: Warn of halt or task clear failure mmc: block: Retry commands in CQE error recovery mmc: block: Be sure to wait while busy in CQE error recovery mmc: cqhci: Increase recovery halt timeout mmc: block: Do not lose cache flush during CQE error recovery
2 parents 1686475 + 477865a commit 09443a1

File tree

5 files changed

+85
-49
lines changed

5 files changed

+85
-49
lines changed

drivers/mmc/core/block.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,8 @@ static void mmc_blk_cqe_complete_rq(struct mmc_queue *mq, struct request *req)
14821482
blk_mq_requeue_request(req, true);
14831483
else
14841484
__blk_mq_end_request(req, BLK_STS_OK);
1485+
} else if (mq->in_recovery) {
1486+
blk_mq_requeue_request(req, true);
14851487
} else {
14861488
blk_mq_end_request(req, BLK_STS_OK);
14871489
}

drivers/mmc/core/core.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,18 +551,23 @@ int mmc_cqe_recovery(struct mmc_host *host)
551551
cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
552552
cmd.flags &= ~MMC_RSP_CRC; /* Ignore CRC */
553553
cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT;
554-
mmc_wait_for_cmd(host, &cmd, 0);
554+
mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
555+
556+
mmc_poll_for_busy(host->card, MMC_CQE_RECOVERY_TIMEOUT, true, MMC_BUSY_IO);
555557

556558
memset(&cmd, 0, sizeof(cmd));
557559
cmd.opcode = MMC_CMDQ_TASK_MGMT;
558560
cmd.arg = 1; /* Discard entire queue */
559561
cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
560562
cmd.flags &= ~MMC_RSP_CRC; /* Ignore CRC */
561563
cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT;
562-
err = mmc_wait_for_cmd(host, &cmd, 0);
564+
err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
563565

564566
host->cqe_ops->cqe_recovery_finish(host);
565567

568+
if (err)
569+
err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
570+
566571
mmc_retune_release(host);
567572

568573
return err;

drivers/mmc/host/cqhci-core.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,8 @@ static bool cqhci_clear_all_tasks(struct mmc_host *mmc, unsigned int timeout)
942942
ret = cqhci_tasks_cleared(cq_host);
943943

944944
if (!ret)
945-
pr_debug("%s: cqhci: Failed to clear tasks\n",
946-
mmc_hostname(mmc));
945+
pr_warn("%s: cqhci: Failed to clear tasks\n",
946+
mmc_hostname(mmc));
947947

948948
return ret;
949949
}
@@ -976,18 +976,18 @@ static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout)
976976
ret = cqhci_halted(cq_host);
977977

978978
if (!ret)
979-
pr_debug("%s: cqhci: Failed to halt\n", mmc_hostname(mmc));
979+
pr_warn("%s: cqhci: Failed to halt\n", mmc_hostname(mmc));
980980

981981
return ret;
982982
}
983983

984984
/*
985985
* After halting we expect to be able to use the command line. We interpret the
986986
* failure to halt to mean the data lines might still be in use (and the upper
987-
* layers will need to send a STOP command), so we set the timeout based on a
988-
* generous command timeout.
987+
* layers will need to send a STOP command), however failing to halt complicates
988+
* the recovery, so set a timeout that would reasonably allow I/O to complete.
989989
*/
990-
#define CQHCI_START_HALT_TIMEOUT 5
990+
#define CQHCI_START_HALT_TIMEOUT 500
991991

992992
static void cqhci_recovery_start(struct mmc_host *mmc)
993993
{
@@ -1075,28 +1075,28 @@ static void cqhci_recovery_finish(struct mmc_host *mmc)
10751075

10761076
ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
10771077

1078-
if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
1079-
ok = false;
1080-
10811078
/*
10821079
* The specification contradicts itself, by saying that tasks cannot be
10831080
* cleared if CQHCI does not halt, but if CQHCI does not halt, it should
10841081
* be disabled/re-enabled, but not to disable before clearing tasks.
10851082
* Have a go anyway.
10861083
*/
1087-
if (!ok) {
1088-
pr_debug("%s: cqhci: disable / re-enable\n", mmc_hostname(mmc));
1089-
cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
1090-
cqcfg &= ~CQHCI_ENABLE;
1091-
cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1092-
cqcfg |= CQHCI_ENABLE;
1093-
cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1094-
/* Be sure that there are no tasks */
1095-
ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
1096-
if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
1097-
ok = false;
1098-
WARN_ON(!ok);
1099-
}
1084+
if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
1085+
ok = false;
1086+
1087+
/* Disable to make sure tasks really are cleared */
1088+
cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
1089+
cqcfg &= ~CQHCI_ENABLE;
1090+
cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1091+
1092+
cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
1093+
cqcfg |= CQHCI_ENABLE;
1094+
cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1095+
1096+
cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
1097+
1098+
if (!ok)
1099+
cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT);
11001100

11011101
cqhci_recover_mrqs(cq_host);
11021102

drivers/mmc/host/sdhci-pci-gli.c

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,32 @@ static void gl9763e_hs400_enhanced_strobe(struct mmc_host *mmc,
11891189
sdhci_writel(host, val, SDHCI_GLI_9763E_HS400_ES_REG);
11901190
}
11911191

1192+
static void gl9763e_set_low_power_negotiation(struct sdhci_pci_slot *slot,
1193+
bool enable)
1194+
{
1195+
struct pci_dev *pdev = slot->chip->pdev;
1196+
u32 value;
1197+
1198+
pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value);
1199+
value &= ~GLI_9763E_VHS_REV;
1200+
value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_W);
1201+
pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value);
1202+
1203+
pci_read_config_dword(pdev, PCIE_GLI_9763E_CFG, &value);
1204+
1205+
if (enable)
1206+
value &= ~GLI_9763E_CFG_LPSN_DIS;
1207+
else
1208+
value |= GLI_9763E_CFG_LPSN_DIS;
1209+
1210+
pci_write_config_dword(pdev, PCIE_GLI_9763E_CFG, value);
1211+
1212+
pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value);
1213+
value &= ~GLI_9763E_VHS_REV;
1214+
value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_R);
1215+
pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value);
1216+
}
1217+
11921218
static void sdhci_set_gl9763e_signaling(struct sdhci_host *host,
11931219
unsigned int timing)
11941220
{
@@ -1297,6 +1323,9 @@ static int gl9763e_add_host(struct sdhci_pci_slot *slot)
12971323
if (ret)
12981324
goto cleanup;
12991325

1326+
/* Disable LPM negotiation to avoid entering L1 state. */
1327+
gl9763e_set_low_power_negotiation(slot, false);
1328+
13001329
return 0;
13011330

13021331
cleanup:
@@ -1340,31 +1369,6 @@ static void gli_set_gl9763e(struct sdhci_pci_slot *slot)
13401369
}
13411370

13421371
#ifdef CONFIG_PM
1343-
static void gl9763e_set_low_power_negotiation(struct sdhci_pci_slot *slot, bool enable)
1344-
{
1345-
struct pci_dev *pdev = slot->chip->pdev;
1346-
u32 value;
1347-
1348-
pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value);
1349-
value &= ~GLI_9763E_VHS_REV;
1350-
value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_W);
1351-
pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value);
1352-
1353-
pci_read_config_dword(pdev, PCIE_GLI_9763E_CFG, &value);
1354-
1355-
if (enable)
1356-
value &= ~GLI_9763E_CFG_LPSN_DIS;
1357-
else
1358-
value |= GLI_9763E_CFG_LPSN_DIS;
1359-
1360-
pci_write_config_dword(pdev, PCIE_GLI_9763E_CFG, value);
1361-
1362-
pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value);
1363-
value &= ~GLI_9763E_VHS_REV;
1364-
value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_R);
1365-
pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value);
1366-
}
1367-
13681372
static int gl9763e_runtime_suspend(struct sdhci_pci_chip *chip)
13691373
{
13701374
struct sdhci_pci_slot *slot = chip->slots[0];

drivers/mmc/host/sdhci-sprd.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,33 @@ static void sdhci_sprd_request_done(struct sdhci_host *host,
416416
mmc_request_done(host->mmc, mrq);
417417
}
418418

419+
static void sdhci_sprd_set_power(struct sdhci_host *host, unsigned char mode,
420+
unsigned short vdd)
421+
{
422+
struct mmc_host *mmc = host->mmc;
423+
424+
switch (mode) {
425+
case MMC_POWER_OFF:
426+
mmc_regulator_set_ocr(host->mmc, mmc->supply.vmmc, 0);
427+
428+
mmc_regulator_disable_vqmmc(mmc);
429+
break;
430+
case MMC_POWER_ON:
431+
mmc_regulator_enable_vqmmc(mmc);
432+
break;
433+
case MMC_POWER_UP:
434+
mmc_regulator_set_ocr(host->mmc, mmc->supply.vmmc, vdd);
435+
break;
436+
}
437+
}
438+
419439
static struct sdhci_ops sdhci_sprd_ops = {
420440
.read_l = sdhci_sprd_readl,
421441
.write_l = sdhci_sprd_writel,
422442
.write_w = sdhci_sprd_writew,
423443
.write_b = sdhci_sprd_writeb,
424444
.set_clock = sdhci_sprd_set_clock,
445+
.set_power = sdhci_sprd_set_power,
425446
.get_max_clock = sdhci_sprd_get_max_clock,
426447
.get_min_clock = sdhci_sprd_get_min_clock,
427448
.set_bus_width = sdhci_set_bus_width,
@@ -823,6 +844,10 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
823844
host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 |
824845
SDHCI_SUPPORT_DDR50);
825846

847+
ret = mmc_regulator_get_supply(host->mmc);
848+
if (ret)
849+
goto pm_runtime_disable;
850+
826851
ret = sdhci_setup_host(host);
827852
if (ret)
828853
goto pm_runtime_disable;

0 commit comments

Comments
 (0)