Skip to content

Commit 1282ac4

Browse files
committed
Merge tag 'mmc-v4.4-rc1' of git://git.linaro.org/people/ulf.hansson/mmc
Pull MMC fixes from Ulf Hansson: "Here are some mmc fixes intended for v4.4 rc2. It's based on a commit prior rc1 as I wanted to get them a bit more tested in next before sending you the pull request. MMC core: - Improve reliability when selecting HS200 mode - Improve reliability when selecting HS400 mode - mmc: remove bondage between REQ_META and reliable write MMC host: - pxamci: Fix read-only gpio detection polarity - mtk-sd: Preinitialize delay_phase to fix the case when delay is zero - android-goldfish: Fix build dependency by adding HAS_DMA - dw_mmc: Remove Seungwon Jeon from MAINTAINERS" * tag 'mmc-v4.4-rc1' of git://git.linaro.org/people/ulf.hansson/mmc: mmc: remove bondage between REQ_META and reliable write mmc: MMC_GOLDFISH should depend on HAS_DMA mmc: mediatek: Preinitialize delay_phase in get_best_delay() MAINTAINERS: mmc: Remove Seungwon Jeon from dw_mmc mmc: mmc: Improve reliability of mmc_select_hs400() mmc: mmc: Move mmc_switch_status() mmc: mmc: Fix HS setting in mmc_select_hs400() mmc: mmc: Improve reliability of mmc_select_hs200() mmc: pxamci: fix read-only gpio detection polarity
2 parents 34258a3 + d3df046 commit 1282ac4

File tree

6 files changed

+75
-35
lines changed

6 files changed

+75
-35
lines changed

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9315,7 +9315,6 @@ F: drivers/i2c/busses/i2c-designware-*
93159315
F: include/linux/platform_data/i2c-designware.h
93169316

93179317
SYNOPSYS DESIGNWARE MMC/SD/SDIO DRIVER
9318-
M: Seungwon Jeon <[email protected]>
93199318
M: Jaehoon Chung <[email protected]>
93209319
93219320
S: Maintained

drivers/mmc/card/block.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ MODULE_ALIAS("mmc:block");
6565
#define MMC_SANITIZE_REQ_TIMEOUT 240000
6666
#define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF0000) >> 16)
6767

68-
#define mmc_req_rel_wr(req) (((req->cmd_flags & REQ_FUA) || \
69-
(req->cmd_flags & REQ_META)) && \
68+
#define mmc_req_rel_wr(req) ((req->cmd_flags & REQ_FUA) && \
7069
(rq_data_dir(req) == WRITE))
7170
#define PACKED_CMD_VER 0x01
7271
#define PACKED_CMD_WR 0x02
@@ -1467,13 +1466,9 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
14671466

14681467
/*
14691468
* Reliable writes are used to implement Forced Unit Access and
1470-
* REQ_META accesses, and are supported only on MMCs.
1471-
*
1472-
* XXX: this really needs a good explanation of why REQ_META
1473-
* is treated special.
1469+
* are supported only on MMCs.
14741470
*/
1475-
bool do_rel_wr = ((req->cmd_flags & REQ_FUA) ||
1476-
(req->cmd_flags & REQ_META)) &&
1471+
bool do_rel_wr = (req->cmd_flags & REQ_FUA) &&
14771472
(rq_data_dir(req) == WRITE) &&
14781473
(md->flags & MMC_BLK_REL_WR);
14791474

drivers/mmc/core/mmc.c

Lines changed: 69 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,9 +1040,24 @@ static int mmc_select_hs_ddr(struct mmc_card *card)
10401040
return err;
10411041
}
10421042

1043+
/* Caller must hold re-tuning */
1044+
static int mmc_switch_status(struct mmc_card *card)
1045+
{
1046+
u32 status;
1047+
int err;
1048+
1049+
err = mmc_send_status(card, &status);
1050+
if (err)
1051+
return err;
1052+
1053+
return mmc_switch_status_error(card->host, status);
1054+
}
1055+
10431056
static int mmc_select_hs400(struct mmc_card *card)
10441057
{
10451058
struct mmc_host *host = card->host;
1059+
bool send_status = true;
1060+
unsigned int max_dtr;
10461061
int err = 0;
10471062
u8 val;
10481063

@@ -1053,25 +1068,36 @@ static int mmc_select_hs400(struct mmc_card *card)
10531068
host->ios.bus_width == MMC_BUS_WIDTH_8))
10541069
return 0;
10551070

1056-
/*
1057-
* Before switching to dual data rate operation for HS400,
1058-
* it is required to convert from HS200 mode to HS mode.
1059-
*/
1060-
mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
1061-
mmc_set_bus_speed(card);
1071+
if (host->caps & MMC_CAP_WAIT_WHILE_BUSY)
1072+
send_status = false;
10621073

1074+
/* Reduce frequency to HS frequency */
1075+
max_dtr = card->ext_csd.hs_max_dtr;
1076+
mmc_set_clock(host, max_dtr);
1077+
1078+
/* Switch card to HS mode */
10631079
val = EXT_CSD_TIMING_HS |
10641080
card->drive_strength << EXT_CSD_DRV_STR_SHIFT;
10651081
err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
10661082
EXT_CSD_HS_TIMING, val,
10671083
card->ext_csd.generic_cmd6_time,
1068-
true, true, true);
1084+
true, send_status, true);
10691085
if (err) {
10701086
pr_err("%s: switch to high-speed from hs200 failed, err:%d\n",
10711087
mmc_hostname(host), err);
10721088
return err;
10731089
}
10741090

1091+
/* Set host controller to HS timing */
1092+
mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
1093+
1094+
if (!send_status) {
1095+
err = mmc_switch_status(card);
1096+
if (err)
1097+
goto out_err;
1098+
}
1099+
1100+
/* Switch card to DDR */
10751101
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
10761102
EXT_CSD_BUS_WIDTH,
10771103
EXT_CSD_DDR_BUS_WIDTH_8,
@@ -1082,42 +1108,42 @@ static int mmc_select_hs400(struct mmc_card *card)
10821108
return err;
10831109
}
10841110

1111+
/* Switch card to HS400 */
10851112
val = EXT_CSD_TIMING_HS400 |
10861113
card->drive_strength << EXT_CSD_DRV_STR_SHIFT;
10871114
err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
10881115
EXT_CSD_HS_TIMING, val,
10891116
card->ext_csd.generic_cmd6_time,
1090-
true, true, true);
1117+
true, send_status, true);
10911118
if (err) {
10921119
pr_err("%s: switch to hs400 failed, err:%d\n",
10931120
mmc_hostname(host), err);
10941121
return err;
10951122
}
10961123

1124+
/* Set host controller to HS400 timing and frequency */
10971125
mmc_set_timing(host, MMC_TIMING_MMC_HS400);
10981126
mmc_set_bus_speed(card);
10991127

1128+
if (!send_status) {
1129+
err = mmc_switch_status(card);
1130+
if (err)
1131+
goto out_err;
1132+
}
1133+
11001134
return 0;
1135+
1136+
out_err:
1137+
pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host),
1138+
__func__, err);
1139+
return err;
11011140
}
11021141

11031142
int mmc_hs200_to_hs400(struct mmc_card *card)
11041143
{
11051144
return mmc_select_hs400(card);
11061145
}
11071146

1108-
/* Caller must hold re-tuning */
1109-
static int mmc_switch_status(struct mmc_card *card)
1110-
{
1111-
u32 status;
1112-
int err;
1113-
1114-
err = mmc_send_status(card, &status);
1115-
if (err)
1116-
return err;
1117-
1118-
return mmc_switch_status_error(card->host, status);
1119-
}
1120-
11211147
int mmc_hs400_to_hs200(struct mmc_card *card)
11221148
{
11231149
struct mmc_host *host = card->host;
@@ -1219,6 +1245,8 @@ static void mmc_select_driver_type(struct mmc_card *card)
12191245
static int mmc_select_hs200(struct mmc_card *card)
12201246
{
12211247
struct mmc_host *host = card->host;
1248+
bool send_status = true;
1249+
unsigned int old_timing;
12221250
int err = -EINVAL;
12231251
u8 val;
12241252

@@ -1234,6 +1262,9 @@ static int mmc_select_hs200(struct mmc_card *card)
12341262

12351263
mmc_select_driver_type(card);
12361264

1265+
if (host->caps & MMC_CAP_WAIT_WHILE_BUSY)
1266+
send_status = false;
1267+
12371268
/*
12381269
* Set the bus width(4 or 8) with host's support and
12391270
* switch to HS200 mode if bus width is set successfully.
@@ -1245,11 +1276,25 @@ static int mmc_select_hs200(struct mmc_card *card)
12451276
err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
12461277
EXT_CSD_HS_TIMING, val,
12471278
card->ext_csd.generic_cmd6_time,
1248-
true, true, true);
1249-
if (!err)
1250-
mmc_set_timing(host, MMC_TIMING_MMC_HS200);
1279+
true, send_status, true);
1280+
if (err)
1281+
goto err;
1282+
old_timing = host->ios.timing;
1283+
mmc_set_timing(host, MMC_TIMING_MMC_HS200);
1284+
if (!send_status) {
1285+
err = mmc_switch_status(card);
1286+
/*
1287+
* mmc_select_timing() assumes timing has not changed if
1288+
* it is a switch error.
1289+
*/
1290+
if (err == -EBADMSG)
1291+
mmc_set_timing(host, old_timing);
1292+
}
12511293
}
12521294
err:
1295+
if (err)
1296+
pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host),
1297+
__func__, err);
12531298
return err;
12541299
}
12551300

drivers/mmc/host/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ config MMC_DAVINCI
473473

474474
config MMC_GOLDFISH
475475
tristate "goldfish qemu Multimedia Card Interface support"
476+
depends on HAS_DMA
476477
depends on GOLDFISH || COMPILE_TEST
477478
help
478479
This selects the Goldfish Multimedia card Interface emulation

drivers/mmc/host/mtk-sd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ static struct msdc_delay_phase get_best_delay(struct msdc_host *host, u32 delay)
12761276
int start = 0, len = 0;
12771277
int start_final = 0, len_final = 0;
12781278
u8 final_phase = 0xff;
1279-
struct msdc_delay_phase delay_phase;
1279+
struct msdc_delay_phase delay_phase = { 0, };
12801280

12811281
if (delay == 0) {
12821282
dev_err(host->dev, "phase error: [map:%x]\n", delay);

drivers/mmc/host/pxamci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ static int pxamci_probe(struct platform_device *pdev)
805805
goto out;
806806
} else {
807807
mmc->caps |= host->pdata->gpio_card_ro_invert ?
808-
MMC_CAP2_RO_ACTIVE_HIGH : 0;
808+
0 : MMC_CAP2_RO_ACTIVE_HIGH;
809809
}
810810

811811
if (gpio_is_valid(gpio_cd))

0 commit comments

Comments
 (0)