Skip to content

Commit 7da6c04

Browse files
committed
Merge tag 'mmc-v6.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: "MMC core: - Capture correct oemid-bits for eMMC cards - Fix error propagation for some ioctl commands - Hold retuning if SDIO is in 1-bit mode MMC host: - mtk-sd: Use readl_poll_timeout_atomic to not "schedule while atomic" - sdhci-msm: Correct minimum number of clocks - sdhci-pci-gli: Fix LPM negotiation so x86/S0ix SoCs can suspend - sdhci-sprd: Fix error code in sdhci_sprd_tuning()" * tag 'mmc-v6.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: core: Capture correct oemid-bits for eMMC cards mmc: mtk-sd: Use readl_poll_timeout_atomic in msdc_reset_hw mmc: core: Fix error propagation for some ioctl commands mmc: sdhci-sprd: Fix error code in sdhci_sprd_tuning() mmc: sdhci-pci-gli: fix LPM negotiation so x86/S0ix SoCs can suspend mmc: core: sdio: hold retuning if sdio in 1-bit mode dt-bindings: mmc: sdhci-msm: correct minimum number of clocks
2 parents c320008 + 84ee19b commit 7da6c04

File tree

7 files changed

+99
-55
lines changed

7 files changed

+99
-55
lines changed

Documentation/devicetree/bindings/mmc/sdhci-msm.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ properties:
6969
maxItems: 4
7070

7171
clocks:
72-
minItems: 3
72+
minItems: 2
7373
items:
7474
- description: Main peripheral bus clock, PCLK/HCLK - AHB Bus clock
7575
- description: SDC MMC clock, MCLK

drivers/mmc/core/block.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
179179
struct mmc_queue *mq);
180180
static void mmc_blk_hsq_req_done(struct mmc_request *mrq);
181181
static int mmc_spi_err_check(struct mmc_card *card);
182+
static int mmc_blk_busy_cb(void *cb_data, bool *busy);
182183

183184
static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk)
184185
{
@@ -470,7 +471,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
470471
struct mmc_data data = {};
471472
struct mmc_request mrq = {};
472473
struct scatterlist sg;
473-
bool r1b_resp, use_r1b_resp = false;
474+
bool r1b_resp;
474475
unsigned int busy_timeout_ms;
475476
int err;
476477
unsigned int target_part;
@@ -551,8 +552,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
551552
busy_timeout_ms = idata->ic.cmd_timeout_ms ? : MMC_BLK_TIMEOUT_MS;
552553
r1b_resp = (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B;
553554
if (r1b_resp)
554-
use_r1b_resp = mmc_prepare_busy_cmd(card->host, &cmd,
555-
busy_timeout_ms);
555+
mmc_prepare_busy_cmd(card->host, &cmd, busy_timeout_ms);
556556

557557
mmc_wait_for_req(card->host, &mrq);
558558
memcpy(&idata->ic.response, cmd.resp, sizeof(cmd.resp));
@@ -605,19 +605,28 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
605605
if (idata->ic.postsleep_min_us)
606606
usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);
607607

608-
/* No need to poll when using HW busy detection. */
609-
if ((card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp)
610-
return 0;
611-
612608
if (mmc_host_is_spi(card->host)) {
613609
if (idata->ic.write_flag || r1b_resp || cmd.flags & MMC_RSP_SPI_BUSY)
614610
return mmc_spi_err_check(card);
615611
return err;
616612
}
617-
/* Ensure RPMB/R1B command has completed by polling with CMD13. */
618-
if (idata->rpmb || r1b_resp)
619-
err = mmc_poll_for_busy(card, busy_timeout_ms, false,
620-
MMC_BUSY_IO);
613+
614+
/*
615+
* Ensure RPMB, writes and R1B responses are completed by polling with
616+
* CMD13. Note that, usually we don't need to poll when using HW busy
617+
* detection, but here it's needed since some commands may indicate the
618+
* error through the R1 status bits.
619+
*/
620+
if (idata->rpmb || idata->ic.write_flag || r1b_resp) {
621+
struct mmc_blk_busy_data cb_data = {
622+
.card = card,
623+
};
624+
625+
err = __mmc_poll_for_busy(card->host, 0, busy_timeout_ms,
626+
&mmc_blk_busy_cb, &cb_data);
627+
628+
idata->ic.response[0] = cb_data.status;
629+
}
621630

622631
return err;
623632
}

drivers/mmc/core/mmc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static int mmc_decode_cid(struct mmc_card *card)
104104
case 3: /* MMC v3.1 - v3.3 */
105105
case 4: /* MMC v4 */
106106
card->cid.manfid = UNSTUFF_BITS(resp, 120, 8);
107-
card->cid.oemid = UNSTUFF_BITS(resp, 104, 16);
107+
card->cid.oemid = UNSTUFF_BITS(resp, 104, 8);
108108
card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8);
109109
card->cid.prod_name[1] = UNSTUFF_BITS(resp, 88, 8);
110110
card->cid.prod_name[2] = UNSTUFF_BITS(resp, 80, 8);

drivers/mmc/core/sdio.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,8 +1089,14 @@ static int mmc_sdio_resume(struct mmc_host *host)
10891089
}
10901090
err = mmc_sdio_reinit_card(host);
10911091
} else if (mmc_card_wake_sdio_irq(host)) {
1092-
/* We may have switched to 1-bit mode during suspend */
1092+
/*
1093+
* We may have switched to 1-bit mode during suspend,
1094+
* need to hold retuning, because tuning only supprt
1095+
* 4-bit mode or 8 bit mode.
1096+
*/
1097+
mmc_retune_hold_now(host);
10931098
err = sdio_enable_4bit_bus(host->card);
1099+
mmc_retune_release(host);
10941100
}
10951101

10961102
if (err)

drivers/mmc/host/mtk-sd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,11 +669,11 @@ static void msdc_reset_hw(struct msdc_host *host)
669669
u32 val;
670670

671671
sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_RST);
672-
readl_poll_timeout(host->base + MSDC_CFG, val, !(val & MSDC_CFG_RST), 0, 0);
672+
readl_poll_timeout_atomic(host->base + MSDC_CFG, val, !(val & MSDC_CFG_RST), 0, 0);
673673

674674
sdr_set_bits(host->base + MSDC_FIFOCS, MSDC_FIFOCS_CLR);
675-
readl_poll_timeout(host->base + MSDC_FIFOCS, val,
676-
!(val & MSDC_FIFOCS_CLR), 0, 0);
675+
readl_poll_timeout_atomic(host->base + MSDC_FIFOCS, val,
676+
!(val & MSDC_FIFOCS_CLR), 0, 0);
677677

678678
val = readl(host->base + MSDC_INT);
679679
writel(val, host->base + MSDC_INT);

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

Lines changed: 66 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,42 +1144,6 @@ static u32 sdhci_gl9750_readl(struct sdhci_host *host, int reg)
11441144
return value;
11451145
}
11461146

1147-
#ifdef CONFIG_PM_SLEEP
1148-
static int sdhci_pci_gli_resume(struct sdhci_pci_chip *chip)
1149-
{
1150-
struct sdhci_pci_slot *slot = chip->slots[0];
1151-
1152-
pci_free_irq_vectors(slot->chip->pdev);
1153-
gli_pcie_enable_msi(slot);
1154-
1155-
return sdhci_pci_resume_host(chip);
1156-
}
1157-
1158-
static int sdhci_cqhci_gli_resume(struct sdhci_pci_chip *chip)
1159-
{
1160-
struct sdhci_pci_slot *slot = chip->slots[0];
1161-
int ret;
1162-
1163-
ret = sdhci_pci_gli_resume(chip);
1164-
if (ret)
1165-
return ret;
1166-
1167-
return cqhci_resume(slot->host->mmc);
1168-
}
1169-
1170-
static int sdhci_cqhci_gli_suspend(struct sdhci_pci_chip *chip)
1171-
{
1172-
struct sdhci_pci_slot *slot = chip->slots[0];
1173-
int ret;
1174-
1175-
ret = cqhci_suspend(slot->host->mmc);
1176-
if (ret)
1177-
return ret;
1178-
1179-
return sdhci_suspend_host(slot->host);
1180-
}
1181-
#endif
1182-
11831147
static void gl9763e_hs400_enhanced_strobe(struct mmc_host *mmc,
11841148
struct mmc_ios *ios)
11851149
{
@@ -1420,6 +1384,70 @@ static int gl9763e_runtime_resume(struct sdhci_pci_chip *chip)
14201384
}
14211385
#endif
14221386

1387+
#ifdef CONFIG_PM_SLEEP
1388+
static int sdhci_pci_gli_resume(struct sdhci_pci_chip *chip)
1389+
{
1390+
struct sdhci_pci_slot *slot = chip->slots[0];
1391+
1392+
pci_free_irq_vectors(slot->chip->pdev);
1393+
gli_pcie_enable_msi(slot);
1394+
1395+
return sdhci_pci_resume_host(chip);
1396+
}
1397+
1398+
static int gl9763e_resume(struct sdhci_pci_chip *chip)
1399+
{
1400+
struct sdhci_pci_slot *slot = chip->slots[0];
1401+
int ret;
1402+
1403+
ret = sdhci_pci_gli_resume(chip);
1404+
if (ret)
1405+
return ret;
1406+
1407+
ret = cqhci_resume(slot->host->mmc);
1408+
if (ret)
1409+
return ret;
1410+
1411+
/*
1412+
* Disable LPM negotiation to bring device back in sync
1413+
* with its runtime_pm state.
1414+
*/
1415+
gl9763e_set_low_power_negotiation(slot, false);
1416+
1417+
return 0;
1418+
}
1419+
1420+
static int gl9763e_suspend(struct sdhci_pci_chip *chip)
1421+
{
1422+
struct sdhci_pci_slot *slot = chip->slots[0];
1423+
int ret;
1424+
1425+
/*
1426+
* Certain SoCs can suspend only with the bus in low-
1427+
* power state, notably x86 SoCs when using S0ix.
1428+
* Re-enable LPM negotiation to allow entering L1 state
1429+
* and entering system suspend.
1430+
*/
1431+
gl9763e_set_low_power_negotiation(slot, true);
1432+
1433+
ret = cqhci_suspend(slot->host->mmc);
1434+
if (ret)
1435+
goto err_suspend;
1436+
1437+
ret = sdhci_suspend_host(slot->host);
1438+
if (ret)
1439+
goto err_suspend_host;
1440+
1441+
return 0;
1442+
1443+
err_suspend_host:
1444+
cqhci_resume(slot->host->mmc);
1445+
err_suspend:
1446+
gl9763e_set_low_power_negotiation(slot, false);
1447+
return ret;
1448+
}
1449+
#endif
1450+
14231451
static int gli_probe_slot_gl9763e(struct sdhci_pci_slot *slot)
14241452
{
14251453
struct pci_dev *pdev = slot->chip->pdev;
@@ -1527,8 +1555,8 @@ const struct sdhci_pci_fixes sdhci_gl9763e = {
15271555
.probe_slot = gli_probe_slot_gl9763e,
15281556
.ops = &sdhci_gl9763e_ops,
15291557
#ifdef CONFIG_PM_SLEEP
1530-
.resume = sdhci_cqhci_gli_resume,
1531-
.suspend = sdhci_cqhci_gli_suspend,
1558+
.resume = gl9763e_resume,
1559+
.suspend = gl9763e_suspend,
15321560
#endif
15331561
#ifdef CONFIG_PM
15341562
.runtime_suspend = gl9763e_runtime_suspend,

drivers/mmc/host/sdhci-sprd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ static int sdhci_sprd_tuning(struct mmc_host *mmc, struct mmc_card *card,
644644
best_clk_sample = sdhci_sprd_get_best_clk_sample(mmc, value);
645645
if (best_clk_sample < 0) {
646646
dev_err(mmc_dev(host->mmc), "all tuning phase fail!\n");
647+
err = best_clk_sample;
647648
goto out;
648649
}
649650

0 commit comments

Comments
 (0)