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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'mmc-v6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc

Pull MMC fixes from Ulf Hansson:
"MMC core:
- Apply BROKEN_SD_DISCARD quirk earlier during init
- Silence some confusing error messages for SD UHS-II cards

MMC host:
- mtk-sd:
- Prevent memory corruption from DMA map failure
- Fix a pagefault in dma_unmap_sg() for not prepared data
- sdhci: Revert "Disable SD card clock before changing parameters"
- sdhci-of-k1: Fix error code in probe()
- sdhci-uhs2: Silence some confusing error messages for SD UHS-II cards"

* tag 'mmc-v6.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc:
mtk-sd: reset host->mrq on prepare_data() error
Revert "mmc: sdhci: Disable SD card clock before changing parameters"
mmc: sdhci-uhs2: Adjust some error messages and register dump for SD UHS-II card
mmc: sdhci: Add a helper function for dump register in dynamic debug mode
mmc: core: Adjust some error messages for SD UHS-II cards
mtk-sd: Prevent memory corruption from DMA map failure
mtk-sd: Fix a pagefault in dma_unmap_sg() for not prepared data
mmc: sdhci-of-k1: Fix error code in probe()
mmc: core: sd: Apply BROKEN_SD_DISCARD quirk earlier

+57 -28
+6 -6
drivers/mmc/core/quirks.h
··· 44 44 0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd, 45 45 MMC_QUIRK_NO_UHS_DDR50_TUNING, EXT_CSD_REV_ANY), 46 46 47 + /* 48 + * Some SD cards reports discard support while they don't 49 + */ 50 + MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd, 51 + MMC_QUIRK_BROKEN_SD_DISCARD), 52 + 47 53 END_FIXUP 48 54 }; 49 55 ··· 152 146 */ 153 147 MMC_FIXUP("M62704", CID_MANFID_KINGSTON, 0x0100, add_quirk_mmc, 154 148 MMC_QUIRK_TRIM_BROKEN), 155 - 156 - /* 157 - * Some SD cards reports discard support while they don't 158 - */ 159 - MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd, 160 - MMC_QUIRK_BROKEN_SD_DISCARD), 161 149 162 150 END_FIXUP 163 151 };
+2 -2
drivers/mmc/core/sd_uhs2.c
··· 91 91 92 92 err = host->ops->uhs2_control(host, UHS2_PHY_INIT); 93 93 if (err) { 94 - pr_err("%s: failed to initial phy for UHS-II!\n", 95 - mmc_hostname(host)); 94 + pr_debug("%s: failed to initial phy for UHS-II!\n", 95 + mmc_hostname(host)); 96 96 } 97 97 98 98 return err;
+19 -2
drivers/mmc/host/mtk-sd.c
··· 846 846 static void msdc_prepare_data(struct msdc_host *host, struct mmc_data *data) 847 847 { 848 848 if (!(data->host_cookie & MSDC_PREPARE_FLAG)) { 849 - data->host_cookie |= MSDC_PREPARE_FLAG; 850 849 data->sg_count = dma_map_sg(host->dev, data->sg, data->sg_len, 851 850 mmc_get_dma_dir(data)); 851 + if (data->sg_count) 852 + data->host_cookie |= MSDC_PREPARE_FLAG; 852 853 } 854 + } 855 + 856 + static bool msdc_data_prepared(struct mmc_data *data) 857 + { 858 + return data->host_cookie & MSDC_PREPARE_FLAG; 853 859 } 854 860 855 861 static void msdc_unprepare_data(struct msdc_host *host, struct mmc_data *data) ··· 1489 1483 WARN_ON(!host->hsq_en && host->mrq); 1490 1484 host->mrq = mrq; 1491 1485 1492 - if (mrq->data) 1486 + if (mrq->data) { 1493 1487 msdc_prepare_data(host, mrq->data); 1488 + if (!msdc_data_prepared(mrq->data)) { 1489 + host->mrq = NULL; 1490 + /* 1491 + * Failed to prepare DMA area, fail fast before 1492 + * starting any commands. 1493 + */ 1494 + mrq->cmd->error = -ENOSPC; 1495 + mmc_request_done(mmc_from_priv(host), mrq); 1496 + return; 1497 + } 1498 + } 1494 1499 1495 1500 /* if SBC is required, we have HW option and SW option. 1496 1501 * if HW option is enabled, and SBC does not have "special" flags,
+2 -1
drivers/mmc/host/sdhci-of-k1.c
··· 276 276 277 277 host->mmc->caps |= MMC_CAP_NEED_RSP_BUSY; 278 278 279 - if (spacemit_sdhci_get_clocks(dev, pltfm_host)) 279 + ret = spacemit_sdhci_get_clocks(dev, pltfm_host); 280 + if (ret) 280 281 goto err_pltfm; 281 282 282 283 ret = sdhci_add_host(host);
+10 -10
drivers/mmc/host/sdhci-uhs2.c
··· 99 99 /* hw clears the bit when it's done */ 100 100 if (read_poll_timeout_atomic(sdhci_readw, val, !(val & mask), 10, 101 101 UHS2_RESET_TIMEOUT_100MS, true, host, SDHCI_UHS2_SW_RESET)) { 102 - pr_warn("%s: %s: Reset 0x%x never completed. %s: clean reset bit.\n", __func__, 103 - mmc_hostname(host->mmc), (int)mask, mmc_hostname(host->mmc)); 102 + pr_debug("%s: %s: Reset 0x%x never completed. %s: clean reset bit.\n", __func__, 103 + mmc_hostname(host->mmc), (int)mask, mmc_hostname(host->mmc)); 104 104 sdhci_writeb(host, 0, SDHCI_UHS2_SW_RESET); 105 105 return; 106 106 } ··· 335 335 if (read_poll_timeout(sdhci_readl, val, (val & SDHCI_UHS2_IF_DETECT), 336 336 100, UHS2_INTERFACE_DETECT_TIMEOUT_100MS, true, 337 337 host, SDHCI_PRESENT_STATE)) { 338 - pr_warn("%s: not detect UHS2 interface in 100ms.\n", mmc_hostname(host->mmc)); 339 - sdhci_dumpregs(host); 338 + pr_debug("%s: not detect UHS2 interface in 100ms.\n", mmc_hostname(host->mmc)); 339 + sdhci_dbg_dumpregs(host, "UHS2 interface detect timeout in 100ms"); 340 340 return -EIO; 341 341 } 342 342 ··· 345 345 346 346 if (read_poll_timeout(sdhci_readl, val, (val & SDHCI_UHS2_LANE_SYNC), 347 347 100, UHS2_LANE_SYNC_TIMEOUT_150MS, true, host, SDHCI_PRESENT_STATE)) { 348 - pr_warn("%s: UHS2 Lane sync fail in 150ms.\n", mmc_hostname(host->mmc)); 349 - sdhci_dumpregs(host); 348 + pr_debug("%s: UHS2 Lane sync fail in 150ms.\n", mmc_hostname(host->mmc)); 349 + sdhci_dbg_dumpregs(host, "UHS2 Lane sync fail in 150ms"); 350 350 return -EIO; 351 351 } 352 352 ··· 417 417 host->ops->uhs2_pre_detect_init(host); 418 418 419 419 if (sdhci_uhs2_interface_detect(host)) { 420 - pr_warn("%s: cannot detect UHS2 interface.\n", mmc_hostname(host->mmc)); 420 + pr_debug("%s: cannot detect UHS2 interface.\n", mmc_hostname(host->mmc)); 421 421 return -EIO; 422 422 } 423 423 424 424 if (sdhci_uhs2_init(host)) { 425 - pr_warn("%s: UHS2 init fail.\n", mmc_hostname(host->mmc)); 425 + pr_debug("%s: UHS2 init fail.\n", mmc_hostname(host->mmc)); 426 426 return -EIO; 427 427 } 428 428 ··· 504 504 if (read_poll_timeout(sdhci_readl, val, (val & SDHCI_UHS2_IN_DORMANT_STATE), 505 505 100, UHS2_CHECK_DORMANT_TIMEOUT_100MS, true, host, 506 506 SDHCI_PRESENT_STATE)) { 507 - pr_warn("%s: UHS2 IN_DORMANT fail in 100ms.\n", mmc_hostname(host->mmc)); 508 - sdhci_dumpregs(host); 507 + pr_debug("%s: UHS2 IN_DORMANT fail in 100ms.\n", mmc_hostname(host->mmc)); 508 + sdhci_dbg_dumpregs(host, "UHS2 IN_DORMANT fail in 100ms"); 509 509 return -EIO; 510 510 } 511 511 return 0;
+2 -7
drivers/mmc/host/sdhci.c
··· 2065 2065 2066 2066 host->mmc->actual_clock = 0; 2067 2067 2068 - clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); 2069 - if (clk & SDHCI_CLOCK_CARD_EN) 2070 - sdhci_writew(host, clk & ~SDHCI_CLOCK_CARD_EN, 2071 - SDHCI_CLOCK_CONTROL); 2068 + sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL); 2072 2069 2073 - if (clock == 0) { 2074 - sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL); 2070 + if (clock == 0) 2075 2071 return; 2076 - } 2077 2072 2078 2073 clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock); 2079 2074 sdhci_enable_clk(host, clk);
+16
drivers/mmc/host/sdhci.h
··· 900 900 void sdhci_set_data_timeout_irq(struct sdhci_host *host, bool enable); 901 901 void __sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd); 902 902 903 + #if defined(CONFIG_DYNAMIC_DEBUG) || \ 904 + (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) 905 + #define SDHCI_DBG_ANYWAY 0 906 + #elif defined(DEBUG) 907 + #define SDHCI_DBG_ANYWAY 1 908 + #else 909 + #define SDHCI_DBG_ANYWAY 0 910 + #endif 911 + 912 + #define sdhci_dbg_dumpregs(host, fmt) \ 913 + do { \ 914 + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ 915 + if (DYNAMIC_DEBUG_BRANCH(descriptor) || SDHCI_DBG_ANYWAY) \ 916 + sdhci_dumpregs(host); \ 917 + } while (0) 918 + 903 919 #endif /* __SDHCI_HW_H */