Skip to content

Commit 18937b0

Browse files
committed
Merge tag 'mmc-v6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: "MMC core: - Cancel recovery work on cleanup to avoid NULL pointer dereference - Fix error path in the read/write error recovery path - Fix kernel panic when remove non-standard SDIO card - Fix WRITE_ZEROES handling for CQE MMC host: - sdhci_am654: Fixup Kconfig dependency for REGMAP_MMIO - sdhci-esdhc-imx: Avoid warning of misconfigured bus-width - sdhci-pci: Disable broken HS400 ES mode for ASUS BIOS on Jasper Lake" * tag 'mmc-v6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: sdhci_am654: 'select', not 'depends' REGMAP_MMIO mmc: core: Fix WRITE_ZEROES CQE handling mmc: core: Fix kernel panic when remove non-standard SDIO card mmc: sdhci-pci-core: Disable ES for ASUS BIOS on Jasper Lake mmc: sdhci-esdhc-imx: Propagate ESDHC_FLAG_HS400* only on 8bit bus mmc: queue: Cancel recovery work on cleanup mmc: block: Remove error check of hw_reset on reset
2 parents 2eb824f + 8d280b1 commit 18937b0

File tree

6 files changed

+57
-29
lines changed

6 files changed

+57
-29
lines changed

drivers/mmc/core/block.c

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ struct mmc_blk_data {
134134
* track of the current selected device partition.
135135
*/
136136
unsigned int part_curr;
137+
#define MMC_BLK_PART_INVALID UINT_MAX /* Unknown partition active */
137138
int area_type;
138139

139140
/* debugfs files (only in main mmc_blk_data) */
@@ -987,33 +988,39 @@ static unsigned int mmc_blk_data_timeout_ms(struct mmc_host *host,
987988
return ms;
988989
}
989990

991+
/*
992+
* Attempts to reset the card and get back to the requested partition.
993+
* Therefore any error here must result in cancelling the block layer
994+
* request, it must not be reattempted without going through the mmc_blk
995+
* partition sanity checks.
996+
*/
990997
static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
991998
int type)
992999
{
9931000
int err;
1001+
struct mmc_blk_data *main_md = dev_get_drvdata(&host->card->dev);
9941002

9951003
if (md->reset_done & type)
9961004
return -EEXIST;
9971005

9981006
md->reset_done |= type;
9991007
err = mmc_hw_reset(host->card);
1008+
/*
1009+
* A successful reset will leave the card in the main partition, but
1010+
* upon failure it might not be, so set it to MMC_BLK_PART_INVALID
1011+
* in that case.
1012+
*/
1013+
main_md->part_curr = err ? MMC_BLK_PART_INVALID : main_md->part_type;
1014+
if (err)
1015+
return err;
10001016
/* Ensure we switch back to the correct partition */
1001-
if (err) {
1002-
struct mmc_blk_data *main_md =
1003-
dev_get_drvdata(&host->card->dev);
1004-
int part_err;
1005-
1006-
main_md->part_curr = main_md->part_type;
1007-
part_err = mmc_blk_part_switch(host->card, md->part_type);
1008-
if (part_err) {
1009-
/*
1010-
* We have failed to get back into the correct
1011-
* partition, so we need to abort the whole request.
1012-
*/
1013-
return -ENODEV;
1014-
}
1015-
}
1016-
return err;
1017+
if (mmc_blk_part_switch(host->card, md->part_type))
1018+
/*
1019+
* We have failed to get back into the correct
1020+
* partition, so we need to abort the whole request.
1021+
*/
1022+
return -ENODEV;
1023+
return 0;
10171024
}
10181025

10191026
static inline void mmc_blk_reset_success(struct mmc_blk_data *md, int type)
@@ -1871,8 +1878,9 @@ static void mmc_blk_mq_rw_recovery(struct mmc_queue *mq, struct request *req)
18711878
return;
18721879

18731880
/* Reset before last retry */
1874-
if (mqrq->retries + 1 == MMC_MAX_RETRIES)
1875-
mmc_blk_reset(md, card->host, type);
1881+
if (mqrq->retries + 1 == MMC_MAX_RETRIES &&
1882+
mmc_blk_reset(md, card->host, type))
1883+
return;
18761884

18771885
/* Command errors fail fast, so use all MMC_MAX_RETRIES */
18781886
if (brq->sbc.error || brq->cmd.error)

drivers/mmc/core/queue.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static enum mmc_issue_type mmc_cqe_issue_type(struct mmc_host *host,
4848
case REQ_OP_DRV_OUT:
4949
case REQ_OP_DISCARD:
5050
case REQ_OP_SECURE_ERASE:
51+
case REQ_OP_WRITE_ZEROES:
5152
return MMC_ISSUE_SYNC;
5253
case REQ_OP_FLUSH:
5354
return mmc_cqe_can_dcmd(host) ? MMC_ISSUE_DCMD : MMC_ISSUE_SYNC;
@@ -493,6 +494,13 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
493494
if (blk_queue_quiesced(q))
494495
blk_mq_unquiesce_queue(q);
495496

497+
/*
498+
* If the recovery completes the last (and only remaining) request in
499+
* the queue, and the card has been removed, we could end up here with
500+
* the recovery not quite finished yet, so cancel it.
501+
*/
502+
cancel_work_sync(&mq->recovery_work);
503+
496504
blk_mq_free_tag_set(&mq->tag_set);
497505

498506
/*

drivers/mmc/core/sdio_bus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ static void sdio_release_func(struct device *dev)
291291
{
292292
struct sdio_func *func = dev_to_sdio_func(dev);
293293

294-
sdio_free_func_cis(func);
294+
if (!(func->card->quirks & MMC_QUIRK_NONSTD_SDIO))
295+
sdio_free_func_cis(func);
295296

296297
kfree(func->info);
297298
kfree(func->tmpbuf);

drivers/mmc/host/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,9 +1075,10 @@ config MMC_SDHCI_OMAP
10751075

10761076
config MMC_SDHCI_AM654
10771077
tristate "Support for the SDHCI Controller in TI's AM654 SOCs"
1078-
depends on MMC_SDHCI_PLTFM && OF && REGMAP_MMIO
1078+
depends on MMC_SDHCI_PLTFM && OF
10791079
select MMC_SDHCI_IO_ACCESSORS
10801080
select MMC_CQHCI
1081+
select REGMAP_MMIO
10811082
help
10821083
This selects the Secure Digital Host Controller Interface (SDHCI)
10831084
support present in TI's AM654 SOCs. The controller supports

drivers/mmc/host/sdhci-esdhc-imx.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,20 +1660,26 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
16601660
host->mmc_host_ops.execute_tuning = usdhc_execute_tuning;
16611661
}
16621662

1663+
err = sdhci_esdhc_imx_probe_dt(pdev, host, imx_data);
1664+
if (err)
1665+
goto disable_ahb_clk;
1666+
16631667
if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING)
16641668
sdhci_esdhc_ops.platform_execute_tuning =
16651669
esdhc_executing_tuning;
16661670

16671671
if (imx_data->socdata->flags & ESDHC_FLAG_ERR004536)
16681672
host->quirks |= SDHCI_QUIRK_BROKEN_ADMA;
16691673

1670-
if (imx_data->socdata->flags & ESDHC_FLAG_HS400)
1674+
if (host->caps & MMC_CAP_8_BIT_DATA &&
1675+
imx_data->socdata->flags & ESDHC_FLAG_HS400)
16711676
host->mmc->caps2 |= MMC_CAP2_HS400;
16721677

16731678
if (imx_data->socdata->flags & ESDHC_FLAG_BROKEN_AUTO_CMD23)
16741679
host->quirks2 |= SDHCI_QUIRK2_ACMD23_BROKEN;
16751680

1676-
if (imx_data->socdata->flags & ESDHC_FLAG_HS400_ES) {
1681+
if (host->caps & MMC_CAP_8_BIT_DATA &&
1682+
imx_data->socdata->flags & ESDHC_FLAG_HS400_ES) {
16771683
host->mmc->caps2 |= MMC_CAP2_HS400_ES;
16781684
host->mmc_host_ops.hs400_enhanced_strobe =
16791685
esdhc_hs400_enhanced_strobe;
@@ -1695,10 +1701,6 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
16951701
goto disable_ahb_clk;
16961702
}
16971703

1698-
err = sdhci_esdhc_imx_probe_dt(pdev, host, imx_data);
1699-
if (err)
1700-
goto disable_ahb_clk;
1701-
17021704
sdhci_esdhc_imx_hwinit(host);
17031705

17041706
err = sdhci_add_host(host);

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,12 @@ static bool glk_broken_cqhci(struct sdhci_pci_slot *slot)
914914
dmi_match(DMI_SYS_VENDOR, "IRBIS"));
915915
}
916916

917+
static bool jsl_broken_hs400es(struct sdhci_pci_slot *slot)
918+
{
919+
return slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_JSL_EMMC &&
920+
dmi_match(DMI_BIOS_VENDOR, "ASUSTeK COMPUTER INC.");
921+
}
922+
917923
static int glk_emmc_probe_slot(struct sdhci_pci_slot *slot)
918924
{
919925
int ret = byt_emmc_probe_slot(slot);
@@ -922,9 +928,11 @@ static int glk_emmc_probe_slot(struct sdhci_pci_slot *slot)
922928
slot->host->mmc->caps2 |= MMC_CAP2_CQE;
923929

924930
if (slot->chip->pdev->device != PCI_DEVICE_ID_INTEL_GLK_EMMC) {
925-
slot->host->mmc->caps2 |= MMC_CAP2_HS400_ES;
926-
slot->host->mmc_host_ops.hs400_enhanced_strobe =
927-
intel_hs400_enhanced_strobe;
931+
if (!jsl_broken_hs400es(slot)) {
932+
slot->host->mmc->caps2 |= MMC_CAP2_HS400_ES;
933+
slot->host->mmc_host_ops.hs400_enhanced_strobe =
934+
intel_hs400_enhanced_strobe;
935+
}
928936
slot->host->mmc->caps2 |= MMC_CAP2_CQE_DCMD;
929937
}
930938

0 commit comments

Comments
 (0)