Skip to content

Commit 0ccab01

Browse files
committed
Merge tag 'mmc-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC updates from Ulf Hansson: "MMC core: - Improve API to make it clear that mmc_hw_reset() is for cards - Fixup support for writeback-cache for eMMC and SD - Check for errors after writes on SPI MMC host: - renesas_sdhi: A couple of fixes of TAP settings for eMMC HS400 mode - mmci_stm32: Fixup check of all elements in sg list - sdhci-xenon: Revert unnecessary fix for annoying 1.8V regulator warning" * tag 'mmc-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: core: improve API to make clear mmc_hw_reset is for cards mmc: renesas_sdhi: don't overwrite TAP settings when HS400 tuning is complete mmc: renesas_sdhi: special 4tap settings only apply to HS400 mmc: core: Fixup support for writeback-cache for eMMC and SD mmc: block: Check for errors after write on SPI mmc: mmci: stm32: correctly check all elements of sg list Revert "mmc: sdhci-xenon: fix annoying 1.8V regulator warning"
2 parents 02994fd + b71597e commit 0ccab01

11 files changed

Lines changed: 59 additions & 31 deletions

File tree

drivers/mmc/core/block.c

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
993993
return -EEXIST;
994994

995995
md->reset_done |= type;
996-
err = mmc_hw_reset(host);
996+
err = mmc_hw_reset(host->card);
997997
/* Ensure we switch back to the correct partition */
998998
if (err) {
999999
struct mmc_blk_data *main_md =
@@ -1880,6 +1880,31 @@ static inline bool mmc_blk_rq_error(struct mmc_blk_request *brq)
18801880
brq->data.error || brq->cmd.resp[0] & CMD_ERRORS;
18811881
}
18821882

1883+
static int mmc_spi_err_check(struct mmc_card *card)
1884+
{
1885+
u32 status = 0;
1886+
int err;
1887+
1888+
/*
1889+
* SPI does not have a TRAN state we have to wait on, instead the
1890+
* card is ready again when it no longer holds the line LOW.
1891+
* We still have to ensure two things here before we know the write
1892+
* was successful:
1893+
* 1. The card has not disconnected during busy and we actually read our
1894+
* own pull-up, thinking it was still connected, so ensure it
1895+
* still responds.
1896+
* 2. Check for any error bits, in particular R1_SPI_IDLE to catch a
1897+
* just reconnected card after being disconnected during busy.
1898+
*/
1899+
err = __mmc_send_status(card, &status, 0);
1900+
if (err)
1901+
return err;
1902+
/* All R1 and R2 bits of SPI are errors in our case */
1903+
if (status)
1904+
return -EIO;
1905+
return 0;
1906+
}
1907+
18831908
static int mmc_blk_busy_cb(void *cb_data, bool *busy)
18841909
{
18851910
struct mmc_blk_busy_data *data = cb_data;
@@ -1903,9 +1928,16 @@ static int mmc_blk_card_busy(struct mmc_card *card, struct request *req)
19031928
struct mmc_blk_busy_data cb_data;
19041929
int err;
19051930

1906-
if (mmc_host_is_spi(card->host) || rq_data_dir(req) == READ)
1931+
if (rq_data_dir(req) == READ)
19071932
return 0;
19081933

1934+
if (mmc_host_is_spi(card->host)) {
1935+
err = mmc_spi_err_check(card);
1936+
if (err)
1937+
mqrq->brq.data.bytes_xfered = 0;
1938+
return err;
1939+
}
1940+
19091941
cb_data.card = card;
19101942
cb_data.status = 0;
19111943
err = __mmc_poll_for_busy(card->host, 0, MMC_BLK_TIMEOUT_MS,
@@ -2350,6 +2382,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
23502382
struct mmc_blk_data *md;
23512383
int devidx, ret;
23522384
char cap_str[10];
2385+
bool cache_enabled = false;
2386+
bool fua_enabled = false;
23532387

23542388
devidx = ida_simple_get(&mmc_blk_ida, 0, max_devices, GFP_KERNEL);
23552389
if (devidx < 0) {
@@ -2429,13 +2463,17 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
24292463
md->flags |= MMC_BLK_CMD23;
24302464
}
24312465

2432-
if (mmc_card_mmc(card) &&
2433-
md->flags & MMC_BLK_CMD23 &&
2466+
if (md->flags & MMC_BLK_CMD23 &&
24342467
((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) ||
24352468
card->ext_csd.rel_sectors)) {
24362469
md->flags |= MMC_BLK_REL_WR;
2437-
blk_queue_write_cache(md->queue.queue, true, true);
2470+
fua_enabled = true;
2471+
cache_enabled = true;
24382472
}
2473+
if (mmc_cache_enabled(card->host))
2474+
cache_enabled = true;
2475+
2476+
blk_queue_write_cache(md->queue.queue, cache_enabled, fua_enabled);
24392477

24402478
string_get_size((u64)size, 512, STRING_UNITS_2,
24412479
cap_str, sizeof(cap_str));

drivers/mmc/core/core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,16 +1995,17 @@ static void mmc_hw_reset_for_init(struct mmc_host *host)
19951995

19961996
/**
19971997
* mmc_hw_reset - reset the card in hardware
1998-
* @host: MMC host to which the card is attached
1998+
* @card: card to be reset
19991999
*
20002000
* Hard reset the card. This function is only for upper layers, like the
20012001
* block layer or card drivers. You cannot use it in host drivers (struct
20022002
* mmc_card might be gone then).
20032003
*
20042004
* Return: 0 on success, -errno on failure
20052005
*/
2006-
int mmc_hw_reset(struct mmc_host *host)
2006+
int mmc_hw_reset(struct mmc_card *card)
20072007
{
2008+
struct mmc_host *host = card->host;
20082009
int ret;
20092010

20102011
ret = host->bus_ops->hw_reset(host);

drivers/mmc/core/mmc_test.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,10 +2325,9 @@ static int mmc_test_profile_sglen_r_nonblock_perf(struct mmc_test_card *test)
23252325
static int mmc_test_reset(struct mmc_test_card *test)
23262326
{
23272327
struct mmc_card *card = test->card;
2328-
struct mmc_host *host = card->host;
23292328
int err;
23302329

2331-
err = mmc_hw_reset(host);
2330+
err = mmc_hw_reset(card);
23322331
if (!err) {
23332332
/*
23342333
* Reset will re-enable the card's command queue, but tests

drivers/mmc/host/mmci_stm32_sdmmc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ static int sdmmc_idma_validate_data(struct mmci_host *host,
6262
* excepted the last element which has no constraint on idmasize
6363
*/
6464
for_each_sg(data->sg, sg, data->sg_len - 1, i) {
65-
if (!IS_ALIGNED(data->sg->offset, sizeof(u32)) ||
66-
!IS_ALIGNED(data->sg->length, SDMMC_IDMA_BURST)) {
65+
if (!IS_ALIGNED(sg->offset, sizeof(u32)) ||
66+
!IS_ALIGNED(sg->length, SDMMC_IDMA_BURST)) {
6767
dev_err(mmc_dev(host->mmc),
6868
"unaligned scatterlist: ofst:%x length:%d\n",
6969
data->sg->offset, data->sg->length);
7070
return -EINVAL;
7171
}
7272
}
7373

74-
if (!IS_ALIGNED(data->sg->offset, sizeof(u32))) {
74+
if (!IS_ALIGNED(sg->offset, sizeof(u32))) {
7575
dev_err(mmc_dev(host->mmc),
7676
"unaligned last scatterlist: ofst:%x length:%d\n",
7777
data->sg->offset, data->sg->length);

drivers/mmc/host/renesas_sdhi_core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
144144
return clk_get_rate(priv->clk);
145145

146146
if (priv->clkh) {
147+
/* HS400 with 4TAP needs different clock settings */
147148
bool use_4tap = priv->quirks && priv->quirks->hs400_4taps;
148-
bool need_slow_clkh = (host->mmc->ios.timing == MMC_TIMING_UHS_SDR104) ||
149-
(host->mmc->ios.timing == MMC_TIMING_MMC_HS400);
149+
bool need_slow_clkh = host->mmc->ios.timing == MMC_TIMING_MMC_HS400;
150150
clkh_shift = use_4tap && need_slow_clkh ? 1 : 2;
151151
ref_clk = priv->clkh;
152152
}
@@ -396,10 +396,10 @@ static void renesas_sdhi_hs400_complete(struct mmc_host *mmc)
396396
SH_MOBILE_SDHI_SCC_TMPPORT2_HS400OSEL) |
397397
sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2));
398398

399-
/* Set the sampling clock selection range of HS400 mode */
400399
sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_DTCNTL,
401400
SH_MOBILE_SDHI_SCC_DTCNTL_TAPEN |
402-
0x4 << SH_MOBILE_SDHI_SCC_DTCNTL_TAPNUM_SHIFT);
401+
sd_scc_read32(host, priv,
402+
SH_MOBILE_SDHI_SCC_DTCNTL));
403403

404404
/* Avoid bad TAP */
405405
if (bad_taps & BIT(priv->tap_set)) {

drivers/mmc/host/sdhci-xenon.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,6 @@ static void xenon_voltage_switch(struct sdhci_host *host)
241241
{
242242
/* Wait for 5ms after set 1.8V signal enable bit */
243243
usleep_range(5000, 5500);
244-
245-
/*
246-
* For some reason the controller's Host Control2 register reports
247-
* the bit representing 1.8V signaling as 0 when read after it was
248-
* written as 1. Subsequent read reports 1.
249-
*
250-
* Since this may cause some issues, do an empty read of the Host
251-
* Control2 register here to circumvent this.
252-
*/
253-
sdhci_readw(host, SDHCI_HOST_CONTROL2);
254244
}
255245

256246
static unsigned int xenon_get_max_clock(struct sdhci_host *host)

drivers/net/wireless/ath/ath10k/sdio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ static void ath10k_sdio_hif_power_down(struct ath10k *ar)
16331633
return;
16341634
}
16351635

1636-
ret = mmc_hw_reset(ar_sdio->func->card->host);
1636+
ret = mmc_hw_reset(ar_sdio->func->card);
16371637
if (ret)
16381638
ath10k_warn(ar, "unable to reset sdio: %d\n", ret);
16391639

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4165,7 +4165,7 @@ static int brcmf_sdio_bus_reset(struct device *dev)
41654165

41664166
/* reset the adapter */
41674167
sdio_claim_host(sdiodev->func1);
4168-
mmc_hw_reset(sdiodev->func1->card->host);
4168+
mmc_hw_reset(sdiodev->func1->card);
41694169
sdio_release_host(sdiodev->func1);
41704170

41714171
brcmf_bus_change_state(sdiodev->bus_if, BRCMF_BUS_DOWN);

drivers/net/wireless/marvell/mwifiex/sdio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2639,7 +2639,7 @@ static void mwifiex_sdio_card_reset_work(struct mwifiex_adapter *adapter)
26392639

26402640
/* Run a HW reset of the SDIO interface. */
26412641
sdio_claim_host(func);
2642-
ret = mmc_hw_reset(func->card->host);
2642+
ret = mmc_hw_reset(func->card);
26432643
sdio_release_host(func);
26442644

26452645
switch (ret) {

drivers/net/wireless/ti/wlcore/sdio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue)
146146
* To guarantee that the SDIO card is power cycled, as required to make
147147
* the FW programming to succeed, let's do a brute force HW reset.
148148
*/
149-
mmc_hw_reset(card->host);
149+
mmc_hw_reset(card);
150150

151151
sdio_enable_func(func);
152152
sdio_release_host(func);

0 commit comments

Comments
 (0)