Skip to content

Commit d31aeb7

Browse files
committed
Merge tag 'mmc-v4.20-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: "MMC core: - Restore code to allow BKOPS and CACHE ctrl even if no HPI support - Reset HPI enabled state during re-init - Use a default minimum timeout when enabling CACHE ctrl MMC host: - omap_hsmmc: Fix DMA API warning - sdhci-tegra: Fix dt parsing of SDMMC pads autocal values - Correct register accesses when enabling v4 mode" * tag 'mmc-v4.20-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: core: Use a minimum 1600ms timeout when enabling CACHE ctrl mmc: core: Allow BKOPS and CACHE ctrl even if no HPI support mmc: core: Reset HPI enabled state during re-init and in case of errors mmc: omap_hsmmc: fix DMA API warning mmc: tegra: Fix for SDMMC pads autocal parsing from dt mmc: sdhci: Fix sdhci_do_enable_v4_mode
2 parents a837eca + e3ae340 commit d31aeb7

File tree

4 files changed

+32
-16
lines changed

4 files changed

+32
-16
lines changed

drivers/mmc/core/mmc.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "pwrseq.h"
3131

3232
#define DEFAULT_CMD6_TIMEOUT_MS 500
33+
#define MIN_CACHE_EN_TIMEOUT_MS 1600
3334

3435
static const unsigned int tran_exp[] = {
3536
10000, 100000, 1000000, 10000000,
@@ -526,8 +527,7 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
526527
card->cid.year += 16;
527528

528529
/* check whether the eMMC card supports BKOPS */
529-
if (!mmc_card_broken_hpi(card) &&
530-
ext_csd[EXT_CSD_BKOPS_SUPPORT] & 0x1) {
530+
if (ext_csd[EXT_CSD_BKOPS_SUPPORT] & 0x1) {
531531
card->ext_csd.bkops = 1;
532532
card->ext_csd.man_bkops_en =
533533
(ext_csd[EXT_CSD_BKOPS_EN] &
@@ -1782,20 +1782,26 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
17821782
if (err) {
17831783
pr_warn("%s: Enabling HPI failed\n",
17841784
mmc_hostname(card->host));
1785+
card->ext_csd.hpi_en = 0;
17851786
err = 0;
1786-
} else
1787+
} else {
17871788
card->ext_csd.hpi_en = 1;
1789+
}
17881790
}
17891791

17901792
/*
1791-
* If cache size is higher than 0, this indicates
1792-
* the existence of cache and it can be turned on.
1793+
* If cache size is higher than 0, this indicates the existence of cache
1794+
* and it can be turned on. Note that some eMMCs from Micron has been
1795+
* reported to need ~800 ms timeout, while enabling the cache after
1796+
* sudden power failure tests. Let's extend the timeout to a minimum of
1797+
* DEFAULT_CACHE_EN_TIMEOUT_MS and do it for all cards.
17931798
*/
1794-
if (!mmc_card_broken_hpi(card) &&
1795-
card->ext_csd.cache_size > 0) {
1799+
if (card->ext_csd.cache_size > 0) {
1800+
unsigned int timeout_ms = MIN_CACHE_EN_TIMEOUT_MS;
1801+
1802+
timeout_ms = max(card->ext_csd.generic_cmd6_time, timeout_ms);
17961803
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1797-
EXT_CSD_CACHE_CTRL, 1,
1798-
card->ext_csd.generic_cmd6_time);
1804+
EXT_CSD_CACHE_CTRL, 1, timeout_ms);
17991805
if (err && err != -EBADMSG)
18001806
goto free_card;
18011807

drivers/mmc/host/omap_hsmmc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
19091909
mmc->max_blk_size = 512; /* Block Length at max can be 1024 */
19101910
mmc->max_blk_count = 0xFFFF; /* No. of Blocks is 16 bits */
19111911
mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
1912-
mmc->max_seg_size = mmc->max_req_size;
19131912

19141913
mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
19151914
MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_ERASE | MMC_CAP_CMD23;
@@ -1939,6 +1938,17 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
19391938
goto err_irq;
19401939
}
19411940

1941+
/*
1942+
* Limit the maximum segment size to the lower of the request size
1943+
* and the DMA engine device segment size limits. In reality, with
1944+
* 32-bit transfers, the DMA engine can do longer segments than this
1945+
* but there is no way to represent that in the DMA model - if we
1946+
* increase this figure here, we get warnings from the DMA API debug.
1947+
*/
1948+
mmc->max_seg_size = min3(mmc->max_req_size,
1949+
dma_get_max_seg_size(host->rx_chan->device->dev),
1950+
dma_get_max_seg_size(host->tx_chan->device->dev));
1951+
19421952
/* Request IRQ for MMC operations */
19431953
ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0,
19441954
mmc_hostname(mmc), host);

drivers/mmc/host/sdhci-tegra.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,25 +510,25 @@ static void tegra_sdhci_parse_pad_autocal_dt(struct sdhci_host *host)
510510

511511
err = device_property_read_u32(host->mmc->parent,
512512
"nvidia,pad-autocal-pull-up-offset-3v3-timeout",
513-
&autocal->pull_up_3v3);
513+
&autocal->pull_up_3v3_timeout);
514514
if (err)
515515
autocal->pull_up_3v3_timeout = 0;
516516

517517
err = device_property_read_u32(host->mmc->parent,
518518
"nvidia,pad-autocal-pull-down-offset-3v3-timeout",
519-
&autocal->pull_down_3v3);
519+
&autocal->pull_down_3v3_timeout);
520520
if (err)
521521
autocal->pull_down_3v3_timeout = 0;
522522

523523
err = device_property_read_u32(host->mmc->parent,
524524
"nvidia,pad-autocal-pull-up-offset-1v8-timeout",
525-
&autocal->pull_up_1v8);
525+
&autocal->pull_up_1v8_timeout);
526526
if (err)
527527
autocal->pull_up_1v8_timeout = 0;
528528

529529
err = device_property_read_u32(host->mmc->parent,
530530
"nvidia,pad-autocal-pull-down-offset-1v8-timeout",
531-
&autocal->pull_down_1v8);
531+
&autocal->pull_down_1v8_timeout);
532532
if (err)
533533
autocal->pull_down_1v8_timeout = 0;
534534

drivers/mmc/host/sdhci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ static void sdhci_do_enable_v4_mode(struct sdhci_host *host)
127127
{
128128
u16 ctrl2;
129129

130-
ctrl2 = sdhci_readb(host, SDHCI_HOST_CONTROL2);
130+
ctrl2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
131131
if (ctrl2 & SDHCI_CTRL_V4_MODE)
132132
return;
133133

134134
ctrl2 |= SDHCI_CTRL_V4_MODE;
135-
sdhci_writeb(host, ctrl2, SDHCI_HOST_CONTROL);
135+
sdhci_writew(host, ctrl2, SDHCI_HOST_CONTROL2);
136136
}
137137

138138
/*

0 commit comments

Comments
 (0)