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
This commit is contained in:
@@ -44,6 +44,12 @@ static const struct mmc_fixup __maybe_unused mmc_sd_fixups[] = {
|
||||
0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd,
|
||||
MMC_QUIRK_NO_UHS_DDR50_TUNING, EXT_CSD_REV_ANY),
|
||||
|
||||
/*
|
||||
* Some SD cards reports discard support while they don't
|
||||
*/
|
||||
MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd,
|
||||
MMC_QUIRK_BROKEN_SD_DISCARD),
|
||||
|
||||
END_FIXUP
|
||||
};
|
||||
|
||||
@@ -147,12 +153,6 @@ static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {
|
||||
MMC_FIXUP("M62704", CID_MANFID_KINGSTON, 0x0100, add_quirk_mmc,
|
||||
MMC_QUIRK_TRIM_BROKEN),
|
||||
|
||||
/*
|
||||
* Some SD cards reports discard support while they don't
|
||||
*/
|
||||
MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd,
|
||||
MMC_QUIRK_BROKEN_SD_DISCARD),
|
||||
|
||||
END_FIXUP
|
||||
};
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ static int sd_uhs2_phy_init(struct mmc_host *host)
|
||||
|
||||
err = host->ops->uhs2_control(host, UHS2_PHY_INIT);
|
||||
if (err) {
|
||||
pr_err("%s: failed to initial phy for UHS-II!\n",
|
||||
mmc_hostname(host));
|
||||
pr_debug("%s: failed to initial phy for UHS-II!\n",
|
||||
mmc_hostname(host));
|
||||
}
|
||||
|
||||
return err;
|
||||
|
||||
@@ -846,12 +846,18 @@ static inline void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma,
|
||||
static void msdc_prepare_data(struct msdc_host *host, struct mmc_data *data)
|
||||
{
|
||||
if (!(data->host_cookie & MSDC_PREPARE_FLAG)) {
|
||||
data->host_cookie |= MSDC_PREPARE_FLAG;
|
||||
data->sg_count = dma_map_sg(host->dev, data->sg, data->sg_len,
|
||||
mmc_get_dma_dir(data));
|
||||
if (data->sg_count)
|
||||
data->host_cookie |= MSDC_PREPARE_FLAG;
|
||||
}
|
||||
}
|
||||
|
||||
static bool msdc_data_prepared(struct mmc_data *data)
|
||||
{
|
||||
return data->host_cookie & MSDC_PREPARE_FLAG;
|
||||
}
|
||||
|
||||
static void msdc_unprepare_data(struct msdc_host *host, struct mmc_data *data)
|
||||
{
|
||||
if (data->host_cookie & MSDC_ASYNC_FLAG)
|
||||
@@ -1483,8 +1489,19 @@ static void msdc_ops_request(struct mmc_host *mmc, struct mmc_request *mrq)
|
||||
WARN_ON(!host->hsq_en && host->mrq);
|
||||
host->mrq = mrq;
|
||||
|
||||
if (mrq->data)
|
||||
if (mrq->data) {
|
||||
msdc_prepare_data(host, mrq->data);
|
||||
if (!msdc_data_prepared(mrq->data)) {
|
||||
host->mrq = NULL;
|
||||
/*
|
||||
* Failed to prepare DMA area, fail fast before
|
||||
* starting any commands.
|
||||
*/
|
||||
mrq->cmd->error = -ENOSPC;
|
||||
mmc_request_done(mmc_from_priv(host), mrq);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* if SBC is required, we have HW option and SW option.
|
||||
* if HW option is enabled, and SBC does not have "special" flags,
|
||||
|
||||
@@ -276,7 +276,8 @@ static int spacemit_sdhci_probe(struct platform_device *pdev)
|
||||
|
||||
host->mmc->caps |= MMC_CAP_NEED_RSP_BUSY;
|
||||
|
||||
if (spacemit_sdhci_get_clocks(dev, pltfm_host))
|
||||
ret = spacemit_sdhci_get_clocks(dev, pltfm_host);
|
||||
if (ret)
|
||||
goto err_pltfm;
|
||||
|
||||
ret = sdhci_add_host(host);
|
||||
|
||||
@@ -99,8 +99,8 @@ void sdhci_uhs2_reset(struct sdhci_host *host, u16 mask)
|
||||
/* hw clears the bit when it's done */
|
||||
if (read_poll_timeout_atomic(sdhci_readw, val, !(val & mask), 10,
|
||||
UHS2_RESET_TIMEOUT_100MS, true, host, SDHCI_UHS2_SW_RESET)) {
|
||||
pr_warn("%s: %s: Reset 0x%x never completed. %s: clean reset bit.\n", __func__,
|
||||
mmc_hostname(host->mmc), (int)mask, mmc_hostname(host->mmc));
|
||||
pr_debug("%s: %s: Reset 0x%x never completed. %s: clean reset bit.\n", __func__,
|
||||
mmc_hostname(host->mmc), (int)mask, mmc_hostname(host->mmc));
|
||||
sdhci_writeb(host, 0, SDHCI_UHS2_SW_RESET);
|
||||
return;
|
||||
}
|
||||
@@ -335,8 +335,8 @@ static int sdhci_uhs2_interface_detect(struct sdhci_host *host)
|
||||
if (read_poll_timeout(sdhci_readl, val, (val & SDHCI_UHS2_IF_DETECT),
|
||||
100, UHS2_INTERFACE_DETECT_TIMEOUT_100MS, true,
|
||||
host, SDHCI_PRESENT_STATE)) {
|
||||
pr_warn("%s: not detect UHS2 interface in 100ms.\n", mmc_hostname(host->mmc));
|
||||
sdhci_dumpregs(host);
|
||||
pr_debug("%s: not detect UHS2 interface in 100ms.\n", mmc_hostname(host->mmc));
|
||||
sdhci_dbg_dumpregs(host, "UHS2 interface detect timeout in 100ms");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@@ -345,8 +345,8 @@ static int sdhci_uhs2_interface_detect(struct sdhci_host *host)
|
||||
|
||||
if (read_poll_timeout(sdhci_readl, val, (val & SDHCI_UHS2_LANE_SYNC),
|
||||
100, UHS2_LANE_SYNC_TIMEOUT_150MS, true, host, SDHCI_PRESENT_STATE)) {
|
||||
pr_warn("%s: UHS2 Lane sync fail in 150ms.\n", mmc_hostname(host->mmc));
|
||||
sdhci_dumpregs(host);
|
||||
pr_debug("%s: UHS2 Lane sync fail in 150ms.\n", mmc_hostname(host->mmc));
|
||||
sdhci_dbg_dumpregs(host, "UHS2 Lane sync fail in 150ms");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@@ -417,12 +417,12 @@ static int sdhci_uhs2_do_detect_init(struct mmc_host *mmc)
|
||||
host->ops->uhs2_pre_detect_init(host);
|
||||
|
||||
if (sdhci_uhs2_interface_detect(host)) {
|
||||
pr_warn("%s: cannot detect UHS2 interface.\n", mmc_hostname(host->mmc));
|
||||
pr_debug("%s: cannot detect UHS2 interface.\n", mmc_hostname(host->mmc));
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (sdhci_uhs2_init(host)) {
|
||||
pr_warn("%s: UHS2 init fail.\n", mmc_hostname(host->mmc));
|
||||
pr_debug("%s: UHS2 init fail.\n", mmc_hostname(host->mmc));
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@@ -504,8 +504,8 @@ static int sdhci_uhs2_check_dormant(struct sdhci_host *host)
|
||||
if (read_poll_timeout(sdhci_readl, val, (val & SDHCI_UHS2_IN_DORMANT_STATE),
|
||||
100, UHS2_CHECK_DORMANT_TIMEOUT_100MS, true, host,
|
||||
SDHCI_PRESENT_STATE)) {
|
||||
pr_warn("%s: UHS2 IN_DORMANT fail in 100ms.\n", mmc_hostname(host->mmc));
|
||||
sdhci_dumpregs(host);
|
||||
pr_debug("%s: UHS2 IN_DORMANT fail in 100ms.\n", mmc_hostname(host->mmc));
|
||||
sdhci_dbg_dumpregs(host, "UHS2 IN_DORMANT fail in 100ms");
|
||||
return -EIO;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -2065,15 +2065,10 @@ void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
|
||||
|
||||
host->mmc->actual_clock = 0;
|
||||
|
||||
clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
|
||||
if (clk & SDHCI_CLOCK_CARD_EN)
|
||||
sdhci_writew(host, clk & ~SDHCI_CLOCK_CARD_EN,
|
||||
SDHCI_CLOCK_CONTROL);
|
||||
sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
|
||||
|
||||
if (clock == 0) {
|
||||
sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
|
||||
if (clock == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock);
|
||||
sdhci_enable_clk(host, clk);
|
||||
|
||||
@@ -900,4 +900,20 @@ void sdhci_switch_external_dma(struct sdhci_host *host, bool en);
|
||||
void sdhci_set_data_timeout_irq(struct sdhci_host *host, bool enable);
|
||||
void __sdhci_set_timeout(struct sdhci_host *host, struct mmc_command *cmd);
|
||||
|
||||
#if defined(CONFIG_DYNAMIC_DEBUG) || \
|
||||
(defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE))
|
||||
#define SDHCI_DBG_ANYWAY 0
|
||||
#elif defined(DEBUG)
|
||||
#define SDHCI_DBG_ANYWAY 1
|
||||
#else
|
||||
#define SDHCI_DBG_ANYWAY 0
|
||||
#endif
|
||||
|
||||
#define sdhci_dbg_dumpregs(host, fmt) \
|
||||
do { \
|
||||
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
|
||||
if (DYNAMIC_DEBUG_BRANCH(descriptor) || SDHCI_DBG_ANYWAY) \
|
||||
sdhci_dumpregs(host); \
|
||||
} while (0)
|
||||
|
||||
#endif /* __SDHCI_HW_H */
|
||||
|
||||
Reference in New Issue
Block a user