Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+85 -49
+2
drivers/mmc/core/block.c
··· 1482 1482 blk_mq_requeue_request(req, true); 1483 1483 else 1484 1484 __blk_mq_end_request(req, BLK_STS_OK); 1485 + } else if (mq->in_recovery) { 1486 + blk_mq_requeue_request(req, true); 1485 1487 } else { 1486 1488 blk_mq_end_request(req, BLK_STS_OK); 1487 1489 }
+7 -2
drivers/mmc/core/core.c
··· 551 551 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; 552 552 cmd.flags &= ~MMC_RSP_CRC; /* Ignore CRC */ 553 553 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); 555 557 556 558 memset(&cmd, 0, sizeof(cmd)); 557 559 cmd.opcode = MMC_CMDQ_TASK_MGMT; ··· 561 559 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; 562 560 cmd.flags &= ~MMC_RSP_CRC; /* Ignore CRC */ 563 561 cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT; 564 - err = mmc_wait_for_cmd(host, &cmd, 0); 562 + err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); 565 563 566 564 host->cqe_ops->cqe_recovery_finish(host); 565 + 566 + if (err) 567 + err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); 567 568 568 569 mmc_retune_release(host); 569 570
+22 -22
drivers/mmc/host/cqhci-core.c
··· 942 942 ret = cqhci_tasks_cleared(cq_host); 943 943 944 944 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)); 947 947 948 948 return ret; 949 949 } ··· 976 976 ret = cqhci_halted(cq_host); 977 977 978 978 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)); 980 980 981 981 return ret; 982 982 } ··· 984 984 /* 985 985 * After halting we expect to be able to use the command line. We interpret the 986 986 * 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. 989 989 */ 990 - #define CQHCI_START_HALT_TIMEOUT 5 990 + #define CQHCI_START_HALT_TIMEOUT 500 991 991 992 992 static void cqhci_recovery_start(struct mmc_host *mmc) 993 993 { ··· 1075 1075 1076 1076 ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT); 1077 1077 1078 - if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT)) 1079 - ok = false; 1080 - 1081 1078 /* 1082 1079 * The specification contradicts itself, by saying that tasks cannot be 1083 1080 * cleared if CQHCI does not halt, but if CQHCI does not halt, it should 1084 1081 * be disabled/re-enabled, but not to disable before clearing tasks. 1085 1082 * Have a go anyway. 1086 1083 */ 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); 1100 1100 1101 1101 cqhci_recover_mrqs(cq_host); 1102 1102
+29 -25
drivers/mmc/host/sdhci-pci-gli.c
··· 1189 1189 sdhci_writel(host, val, SDHCI_GLI_9763E_HS400_ES_REG); 1190 1190 } 1191 1191 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 + 1192 1218 static void sdhci_set_gl9763e_signaling(struct sdhci_host *host, 1193 1219 unsigned int timing) 1194 1220 { ··· 1323 1297 if (ret) 1324 1298 goto cleanup; 1325 1299 1300 + /* Disable LPM negotiation to avoid entering L1 state. */ 1301 + gl9763e_set_low_power_negotiation(slot, false); 1302 + 1326 1303 return 0; 1327 1304 1328 1305 cleanup: ··· 1369 1340 } 1370 1341 1371 1342 #ifdef CONFIG_PM 1372 - static void gl9763e_set_low_power_negotiation(struct sdhci_pci_slot *slot, bool enable) 1373 - { 1374 - struct pci_dev *pdev = slot->chip->pdev; 1375 - u32 value; 1376 - 1377 - pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value); 1378 - value &= ~GLI_9763E_VHS_REV; 1379 - value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_W); 1380 - pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value); 1381 - 1382 - pci_read_config_dword(pdev, PCIE_GLI_9763E_CFG, &value); 1383 - 1384 - if (enable) 1385 - value &= ~GLI_9763E_CFG_LPSN_DIS; 1386 - else 1387 - value |= GLI_9763E_CFG_LPSN_DIS; 1388 - 1389 - pci_write_config_dword(pdev, PCIE_GLI_9763E_CFG, value); 1390 - 1391 - pci_read_config_dword(pdev, PCIE_GLI_9763E_VHS, &value); 1392 - value &= ~GLI_9763E_VHS_REV; 1393 - value |= FIELD_PREP(GLI_9763E_VHS_REV, GLI_9763E_VHS_REV_R); 1394 - pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value); 1395 - } 1396 - 1397 1343 static int gl9763e_runtime_suspend(struct sdhci_pci_chip *chip) 1398 1344 { 1399 1345 struct sdhci_pci_slot *slot = chip->slots[0];
+25
drivers/mmc/host/sdhci-sprd.c
··· 416 416 mmc_request_done(host->mmc, mrq); 417 417 } 418 418 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 + 419 439 static struct sdhci_ops sdhci_sprd_ops = { 420 440 .read_l = sdhci_sprd_readl, 421 441 .write_l = sdhci_sprd_writel, 422 442 .write_w = sdhci_sprd_writew, 423 443 .write_b = sdhci_sprd_writeb, 424 444 .set_clock = sdhci_sprd_set_clock, 445 + .set_power = sdhci_sprd_set_power, 425 446 .get_max_clock = sdhci_sprd_get_max_clock, 426 447 .get_min_clock = sdhci_sprd_get_min_clock, 427 448 .set_bus_width = sdhci_set_bus_width, ··· 843 822 sdhci_read_caps(host); 844 823 host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_SDR104 | 845 824 SDHCI_SUPPORT_DDR50); 825 + 826 + ret = mmc_regulator_get_supply(host->mmc); 827 + if (ret) 828 + goto pm_runtime_disable; 846 829 847 830 ret = sdhci_setup_host(host); 848 831 if (ret)