Skip to content

Commit dfabb07

Browse files
committed
Merge tag 'mmc-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC updates from Ulf Hansson: "MMC core: - Add support for host software queue for (e)MMC/SD - Throttle polling rate for CMD6 - Update CMD13 busy condition check for CMD6 commands - Improve busy detect polling for erase/trim/discard/HPI - Fixup support for HW busy detection for HPI commands - Re-work and improve support for eMMC sanitize commands MMC host: - mmci: * Add support for sdmmc variant revision 2.0 - mmci_sdmmc: * Improve support for busyend detection * Fixup support for signal voltage switch * Add support for tuning with delay block - mtk-sd: * Fix another SDIO irq issue - sdhci: * Disable native card detect when GPIO based type exist - sdhci: * Add option to defer request completion - sdhci_am654: * Add support to set a tap value per speed mode - sdhci-esdhc-imx: * Add support for i.MX8MM based variant * Fixup support for standard tuning on i.MX8 usdhc * Optimize for strobe/clock dll settings * Fixup support for system and runtime suspend/resume - sdhci-iproc: * Update regulator/bus-voltage management for bcm2711 - sdhci-msm: * Prevent clock gating with PWRSAVE_DLL on broken variants * Fix management of CQE during SDHCI reset - sdhci-of-arasan: * Add support for auto tuning on ZynqMP based platforms - sdhci-omap: * Add support for system suspend/resume - sdhci-sprd: * Add support for HW busy detection * Enable support host software queue - sdhci-tegra: * Add support for HW busy detection - tmio/renesas_sdhi: * Enforce retune after runtime suspend - renesas_sdhi: * Use manual tap correction for HS400 on some variants * Add support for manual correction of tap values for tunings" * tag 'mmc-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (86 commits) mmc: cavium-octeon: remove nonsense variable coercion mmc: mediatek: fix SDIO irq issue mmc: mmci_sdmmc: Fix clear busyd0end irq flag dt-bindings: mmc: Fix node name in an example mmc: core: Re-work the code for eMMC sanitize mmc: sdhci: use FIELD_GET for preset value bit masks mmc: sdhci-of-at91: Display clock changes for debug purpose only mmc: sdhci: iproc: Add custom set_power() callback for bcm2711 mmc: sdhci: am654: Use sdhci_set_power_and_voltage() mmc: sdhci: at91: Use sdhci_set_power_and_voltage() mmc: sdhci: milbeaut: Use sdhci_set_power_and_voltage() mmc: sdhci: arasan: Use sdhci_set_power_and_voltage() mmc: sdhci: Introduce sdhci_set_power_and_bus_voltage() mmc: vub300: Use scnprintf() for avoiding potential buffer overflow dt-bindings: mmc: synopsys-dw-mshc: fix clock-freq-min-max in example sdhci: tegra: Enable MMC_CAP_WAIT_WHILE_BUSY host capability sdhci: tegra: Implement Tegra specific set_timeout callback mmc: sdhci-omap: Add Support for Suspend/Resume mmc: renesas_sdhi: simplify execute_tuning mmc: renesas_sdhi: Use BITS_PER_LONG helper ...
2 parents 5b67fbf + 92075d9 commit dfabb07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1825
-570
lines changed

Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ Optional properties:
4343
This property allows user to change the tuning step to more than one delay
4444
cells which is useful for some special boards or cards when the default
4545
tuning step can't find the proper delay window within limited tuning retries.
46+
- fsl,strobe-dll-delay-target: Specify the strobe dll control slave delay target.
47+
This delay target programming host controller loopback read clock, and this
48+
property allows user to change the delay target for the strobe input read clock.
49+
If not use this property, driver default set the delay target to value 7.
50+
Only eMMC HS400 mode need to take care of this property.
4651

4752
Examples:
4853

Documentation/devicetree/bindings/mmc/mmc-controller.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ dependencies:
351351

352352
examples:
353353
- |
354-
sdhci@ab000000 {
354+
mmc@ab000000 {
355355
compatible = "sdhci";
356356
reg = <0xab000000 0x200>;
357357
interrupts = <23>;

Documentation/devicetree/bindings/mmc/mmci.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ specific for ux500 variant:
2828
- st,sig-pin-fbclk : feedback clock signal pin used.
2929

3030
specific for sdmmc variant:
31+
- reg : a second base register may be defined if a delay
32+
block is present and used for tuning.
3133
- st,sig-dir : signal direction polarity used for cmd, dat0 dat123.
3234
- st,neg-edge : data & command phase relation, generated on
3335
sd clock falling edge.

Documentation/devicetree/bindings/mmc/sdhci-am654.txt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@ Required Properties:
1818
- clocks: Handles to the clock inputs.
1919
- clock-names: Tuple including "clk_xin" and "clk_ahb"
2020
- interrupts: Interrupt specifiers
21-
- ti,otap-del-sel: Output Tap Delay select
21+
Output tap delay for each speed mode:
22+
- ti,otap-del-sel-legacy
23+
- ti,otap-del-sel-mmc-hs
24+
- ti,otap-del-sel-sd-hs
25+
- ti,otap-del-sel-sdr12
26+
- ti,otap-del-sel-sdr25
27+
- ti,otap-del-sel-sdr50
28+
- ti,otap-del-sel-sdr104
29+
- ti,otap-del-sel-ddr50
30+
- ti,otap-del-sel-ddr52
31+
- ti,otap-del-sel-hs200
32+
- ti,otap-del-sel-hs400
33+
These bindings must be provided otherwise the driver will disable the
34+
corresponding speed mode (i.e. all nodes must provide at least -legacy)
2235

2336
Optional Properties (Required for ti,am654-sdhci-5.1 and ti,j721e-sdhci-8bit):
2437
- ti,trm-icp: DLL trim select
@@ -38,6 +51,10 @@ Example:
3851
interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
3952
sdhci-caps-mask = <0x80000007 0x0>;
4053
mmc-ddr-1_8v;
41-
ti,otap-del-sel = <0x2>;
54+
ti,otap-del-sel-legacy = <0x0>;
55+
ti,otap-del-sel-mmc-hs = <0x0>;
56+
ti,otap-del-sel-ddr52 = <0x5>;
57+
ti,otap-del-sel-hs200 = <0x5>;
58+
ti,otap-del-sel-hs400 = <0x0>;
4259
ti,trm-icp = <0x8>;
4360
};

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ Required properties:
2626

2727
- reg: Base address and length of the register in the following order:
2828
- Host controller register map (required)
29-
- SD Core register map (required for msm-v4 and below)
29+
- SD Core register map (required for controllers earlier than msm-v5)
30+
- CQE register map (Optional, CQE support is present on SDHC instance meant
31+
for eMMC and version v4.2 and above)
32+
- reg-names: When CQE register map is supplied, below reg-names are required
33+
- "hc" for Host controller register map
34+
- "core" for SD core register map
35+
- "cqhci" for CQE register map
3036
- interrupts: Should contain an interrupt-specifiers for the interrupts:
3137
- Host controller interrupt (required)
3238
- pinctrl-names: Should contain only one value - "default".

Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ examples:
6262
cap-mmc-highspeed;
6363
cap-sd-highspeed;
6464
card-detect-delay = <200>;
65-
clock-freq-min-max = <400000 200000000>;
65+
max-frequency = <200000000>;
6666
clock-frequency = <400000000>;
6767
data-addr = <0x200>;
6868
fifo-depth = <0x80>;

drivers/firmware/xilinx/zynqmp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ static int zynqmp_pm_clock_getparent(u32 clock_id, u32 *parent_id)
512512
static inline int zynqmp_is_valid_ioctl(u32 ioctl_id)
513513
{
514514
switch (ioctl_id) {
515+
case IOCTL_SD_DLL_RESET:
516+
case IOCTL_SET_SD_TAPDELAY:
515517
case IOCTL_SET_PLL_FRAC_MODE:
516518
case IOCTL_GET_PLL_FRAC_MODE:
517519
case IOCTL_SET_PLL_FRAC_DATA:

drivers/mmc/core/block.c

Lines changed: 67 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ MODULE_ALIAS("mmc:block");
7070
* ample.
7171
*/
7272
#define MMC_BLK_TIMEOUT_MS (10 * 1000)
73-
#define MMC_SANITIZE_REQ_TIMEOUT 240000
7473
#define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF0000) >> 16)
7574
#define MMC_EXTRACT_VALUE_FROM_ARG(x) ((x & 0x0000FF00) >> 8)
7675

@@ -168,6 +167,11 @@ MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device");
168167

169168
static inline int mmc_blk_part_switch(struct mmc_card *card,
170169
unsigned int part_type);
170+
static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
171+
struct mmc_card *card,
172+
int disable_multi,
173+
struct mmc_queue *mq);
174+
static void mmc_blk_hsq_req_done(struct mmc_request *mrq);
171175

172176
static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk)
173177
{
@@ -408,44 +412,6 @@ static int mmc_blk_ioctl_copy_to_user(struct mmc_ioc_cmd __user *ic_ptr,
408412
return 0;
409413
}
410414

411-
static int ioctl_do_sanitize(struct mmc_card *card)
412-
{
413-
int err;
414-
415-
if (!mmc_can_sanitize(card)) {
416-
pr_warn("%s: %s - SANITIZE is not supported\n",
417-
mmc_hostname(card->host), __func__);
418-
err = -EOPNOTSUPP;
419-
goto out;
420-
}
421-
422-
pr_debug("%s: %s - SANITIZE IN PROGRESS...\n",
423-
mmc_hostname(card->host), __func__);
424-
425-
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
426-
EXT_CSD_SANITIZE_START, 1,
427-
MMC_SANITIZE_REQ_TIMEOUT);
428-
429-
if (err)
430-
pr_err("%s: %s - EXT_CSD_SANITIZE_START failed. err=%d\n",
431-
mmc_hostname(card->host), __func__, err);
432-
433-
pr_debug("%s: %s - SANITIZE COMPLETED\n", mmc_hostname(card->host),
434-
__func__);
435-
out:
436-
return err;
437-
}
438-
439-
static inline bool mmc_blk_in_tran_state(u32 status)
440-
{
441-
/*
442-
* Some cards mishandle the status bits, so make sure to check both the
443-
* busy indication and the card state.
444-
*/
445-
return status & R1_READY_FOR_DATA &&
446-
(R1_CURRENT_STATE(status) == R1_STATE_TRAN);
447-
}
448-
449415
static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
450416
u32 *resp_errs)
451417
{
@@ -477,13 +443,7 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
477443
__func__, status);
478444
return -ETIMEDOUT;
479445
}
480-
481-
/*
482-
* Some cards mishandle the status bits,
483-
* so make sure to check both the busy
484-
* indication and the card state.
485-
*/
486-
} while (!mmc_blk_in_tran_state(status));
446+
} while (!mmc_ready_for_data(status));
487447

488448
return err;
489449
}
@@ -580,15 +540,8 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
580540
}
581541

582542
if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_SANITIZE_START) &&
583-
(cmd.opcode == MMC_SWITCH)) {
584-
err = ioctl_do_sanitize(card);
585-
586-
if (err)
587-
pr_err("%s: ioctl_do_sanitize() failed. err = %d",
588-
__func__, err);
589-
590-
return err;
591-
}
543+
(cmd.opcode == MMC_SWITCH))
544+
return mmc_sanitize(card);
592545

593546
mmc_wait_for_req(card->host, &mrq);
594547

@@ -1532,9 +1485,30 @@ static int mmc_blk_cqe_issue_flush(struct mmc_queue *mq, struct request *req)
15321485
return mmc_blk_cqe_start_req(mq->card->host, mrq);
15331486
}
15341487

1488+
static int mmc_blk_hsq_issue_rw_rq(struct mmc_queue *mq, struct request *req)
1489+
{
1490+
struct mmc_queue_req *mqrq = req_to_mmc_queue_req(req);
1491+
struct mmc_host *host = mq->card->host;
1492+
int err;
1493+
1494+
mmc_blk_rw_rq_prep(mqrq, mq->card, 0, mq);
1495+
mqrq->brq.mrq.done = mmc_blk_hsq_req_done;
1496+
mmc_pre_req(host, &mqrq->brq.mrq);
1497+
1498+
err = mmc_cqe_start_req(host, &mqrq->brq.mrq);
1499+
if (err)
1500+
mmc_post_req(host, &mqrq->brq.mrq, err);
1501+
1502+
return err;
1503+
}
1504+
15351505
static int mmc_blk_cqe_issue_rw_rq(struct mmc_queue *mq, struct request *req)
15361506
{
15371507
struct mmc_queue_req *mqrq = req_to_mmc_queue_req(req);
1508+
struct mmc_host *host = mq->card->host;
1509+
1510+
if (host->hsq_enabled)
1511+
return mmc_blk_hsq_issue_rw_rq(mq, req);
15381512

15391513
mmc_blk_data_prep(mq, mqrq, 0, NULL, NULL);
15401514

@@ -1666,7 +1640,7 @@ static void mmc_blk_read_single(struct mmc_queue *mq, struct request *req)
16661640
goto error_exit;
16671641

16681642
if (!mmc_host_is_spi(host) &&
1669-
!mmc_blk_in_tran_state(status)) {
1643+
!mmc_ready_for_data(status)) {
16701644
err = mmc_blk_fix_state(card, req);
16711645
if (err)
16721646
goto error_exit;
@@ -1726,7 +1700,7 @@ static bool mmc_blk_status_error(struct request *req, u32 status)
17261700
return brq->cmd.resp[0] & CMD_ERRORS ||
17271701
brq->stop.resp[0] & stop_err_bits ||
17281702
status & stop_err_bits ||
1729-
(rq_data_dir(req) == WRITE && !mmc_blk_in_tran_state(status));
1703+
(rq_data_dir(req) == WRITE && !mmc_ready_for_data(status));
17301704
}
17311705

17321706
static inline bool mmc_blk_cmd_started(struct mmc_blk_request *brq)
@@ -1788,7 +1762,7 @@ static void mmc_blk_mq_rw_recovery(struct mmc_queue *mq, struct request *req)
17881762

17891763
/* Try to get back to "tran" state */
17901764
if (!mmc_host_is_spi(mq->card->host) &&
1791-
(err || !mmc_blk_in_tran_state(status)))
1765+
(err || !mmc_ready_for_data(status)))
17921766
err = mmc_blk_fix_state(mq->card, req);
17931767

17941768
/*
@@ -1920,6 +1894,41 @@ static void mmc_blk_urgent_bkops(struct mmc_queue *mq,
19201894
mmc_run_bkops(mq->card);
19211895
}
19221896

1897+
static void mmc_blk_hsq_req_done(struct mmc_request *mrq)
1898+
{
1899+
struct mmc_queue_req *mqrq =
1900+
container_of(mrq, struct mmc_queue_req, brq.mrq);
1901+
struct request *req = mmc_queue_req_to_req(mqrq);
1902+
struct request_queue *q = req->q;
1903+
struct mmc_queue *mq = q->queuedata;
1904+
struct mmc_host *host = mq->card->host;
1905+
unsigned long flags;
1906+
1907+
if (mmc_blk_rq_error(&mqrq->brq) ||
1908+
mmc_blk_urgent_bkops_needed(mq, mqrq)) {
1909+
spin_lock_irqsave(&mq->lock, flags);
1910+
mq->recovery_needed = true;
1911+
mq->recovery_req = req;
1912+
spin_unlock_irqrestore(&mq->lock, flags);
1913+
1914+
host->cqe_ops->cqe_recovery_start(host);
1915+
1916+
schedule_work(&mq->recovery_work);
1917+
return;
1918+
}
1919+
1920+
mmc_blk_rw_reset_success(mq, req);
1921+
1922+
/*
1923+
* Block layer timeouts race with completions which means the normal
1924+
* completion path cannot be used during recovery.
1925+
*/
1926+
if (mq->in_recovery)
1927+
mmc_blk_cqe_complete_rq(mq, req);
1928+
else
1929+
blk_mq_complete_request(req);
1930+
}
1931+
19231932
void mmc_blk_mq_complete(struct request *req)
19241933
{
19251934
struct mmc_queue *mq = req->q->queuedata;

drivers/mmc/core/core.c

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -403,23 +403,6 @@ void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq)
403403

404404
cmd = mrq->cmd;
405405

406-
/*
407-
* If host has timed out waiting for the sanitize
408-
* to complete, card might be still in programming state
409-
* so let's try to bring the card out of programming
410-
* state.
411-
*/
412-
if (cmd->sanitize_busy && cmd->error == -ETIMEDOUT) {
413-
if (!mmc_interrupt_hpi(host->card)) {
414-
pr_warn("%s: %s: Interrupted sanitize\n",
415-
mmc_hostname(host), __func__);
416-
cmd->error = 0;
417-
break;
418-
} else {
419-
pr_err("%s: %s: Failed to interrupt sanitize\n",
420-
mmc_hostname(host), __func__);
421-
}
422-
}
423406
if (!cmd->error || !cmd->retries ||
424407
mmc_card_removed(host->card))
425408
break;
@@ -1658,8 +1641,6 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from,
16581641
struct mmc_command cmd = {};
16591642
unsigned int qty = 0, busy_timeout = 0;
16601643
bool use_r1b_resp = false;
1661-
unsigned long timeout;
1662-
int loop_udelay=64, udelay_max=32768;
16631644
int err;
16641645

16651646
mmc_retune_hold(card->host);
@@ -1763,38 +1744,8 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from,
17631744
if ((card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) && use_r1b_resp)
17641745
goto out;
17651746

1766-
timeout = jiffies + msecs_to_jiffies(busy_timeout);
1767-
do {
1768-
memset(&cmd, 0, sizeof(struct mmc_command));
1769-
cmd.opcode = MMC_SEND_STATUS;
1770-
cmd.arg = card->rca << 16;
1771-
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
1772-
/* Do not retry else we can't see errors */
1773-
err = mmc_wait_for_cmd(card->host, &cmd, 0);
1774-
if (err || R1_STATUS(cmd.resp[0])) {
1775-
pr_err("error %d requesting status %#x\n",
1776-
err, cmd.resp[0]);
1777-
err = -EIO;
1778-
goto out;
1779-
}
1780-
1781-
/* Timeout if the device never becomes ready for data and
1782-
* never leaves the program state.
1783-
*/
1784-
if (time_after(jiffies, timeout)) {
1785-
pr_err("%s: Card stuck in programming state! %s\n",
1786-
mmc_hostname(card->host), __func__);
1787-
err = -EIO;
1788-
goto out;
1789-
}
1790-
if ((cmd.resp[0] & R1_READY_FOR_DATA) &&
1791-
R1_CURRENT_STATE(cmd.resp[0]) != R1_STATE_PRG)
1792-
break;
1793-
1794-
usleep_range(loop_udelay, loop_udelay*2);
1795-
if (loop_udelay < udelay_max)
1796-
loop_udelay *= 2;
1797-
} while (1);
1747+
/* Let's poll to find out when the erase operation completes. */
1748+
err = mmc_poll_for_busy(card, busy_timeout, MMC_BUSY_ERASE);
17981749

17991750
out:
18001751
mmc_retune_release(card->host);
@@ -1957,7 +1908,6 @@ int mmc_can_sanitize(struct mmc_card *card)
19571908
return 1;
19581909
return 0;
19591910
}
1960-
EXPORT_SYMBOL(mmc_can_sanitize);
19611911

19621912
int mmc_can_secure_erase_trim(struct mmc_card *card)
19631913
{

0 commit comments

Comments
 (0)