Skip to content

Commit e28e709

Browse files
committed
mmc: sdhci: Centralize CMD and DATA reset handling
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2144641 commit 1e63d29 Author: Adrian Hunter <adrian.hunter@intel.com> Date: Mon, 26 Sep 2022 22:20:22 +0300 Centralize CMD and DATA reset handling so that is more obvious how reset is handled in different situations. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Reviewed-by: Thierry Reding <treding@nvidia.com> Link: https://lore.kernel.org/r/20220926192022.85660-5-adrian.hunter@intel.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Mark Salter <msalter@redhat.com>
1 parent 2ef7da7 commit e28e709

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

drivers/mmc/host/sdhci.c

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,36 @@ static void sdhci_reset_for_all(struct sdhci_host *host)
258258
}
259259
}
260260

261+
enum sdhci_reset_reason {
262+
SDHCI_RESET_FOR_INIT,
263+
SDHCI_RESET_FOR_REQUEST_ERROR,
264+
SDHCI_RESET_FOR_REQUEST_ERROR_DATA_ONLY,
265+
SDHCI_RESET_FOR_TUNING_ABORT,
266+
SDHCI_RESET_FOR_CARD_REMOVED,
267+
SDHCI_RESET_FOR_CQE_RECOVERY,
268+
};
269+
270+
static void sdhci_reset_for_reason(struct sdhci_host *host, enum sdhci_reset_reason reason)
271+
{
272+
switch (reason) {
273+
case SDHCI_RESET_FOR_INIT:
274+
sdhci_do_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
275+
break;
276+
case SDHCI_RESET_FOR_REQUEST_ERROR:
277+
case SDHCI_RESET_FOR_TUNING_ABORT:
278+
case SDHCI_RESET_FOR_CARD_REMOVED:
279+
case SDHCI_RESET_FOR_CQE_RECOVERY:
280+
sdhci_do_reset(host, SDHCI_RESET_CMD);
281+
sdhci_do_reset(host, SDHCI_RESET_DATA);
282+
break;
283+
case SDHCI_RESET_FOR_REQUEST_ERROR_DATA_ONLY:
284+
sdhci_do_reset(host, SDHCI_RESET_DATA);
285+
break;
286+
}
287+
}
288+
289+
#define sdhci_reset_for(h, r) sdhci_reset_for_reason((h), SDHCI_RESET_FOR_##r)
290+
261291
static void sdhci_set_default_irqs(struct sdhci_host *host)
262292
{
263293
host->ier = SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
@@ -326,7 +356,7 @@ static void sdhci_init(struct sdhci_host *host, int soft)
326356
unsigned long flags;
327357

328358
if (soft)
329-
sdhci_do_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
359+
sdhci_reset_for(host, INIT);
330360
else
331361
sdhci_reset_for_all(host);
332362

@@ -1541,8 +1571,9 @@ static void __sdhci_finish_data(struct sdhci_host *host, bool sw_data_timeout)
15411571
*/
15421572
if (data->error) {
15431573
if (!host->cmd || host->cmd == data_cmd)
1544-
sdhci_do_reset(host, SDHCI_RESET_CMD);
1545-
sdhci_do_reset(host, SDHCI_RESET_DATA);
1574+
sdhci_reset_for(host, REQUEST_ERROR);
1575+
else
1576+
sdhci_reset_for(host, REQUEST_ERROR_DATA_ONLY);
15461577
}
15471578

15481579
if ((host->flags & (SDHCI_REQ_USE_DMA | SDHCI_USE_ADMA)) ==
@@ -2710,8 +2741,7 @@ void sdhci_abort_tuning(struct sdhci_host *host, u32 opcode)
27102741
{
27112742
sdhci_reset_tuning(host);
27122743

2713-
sdhci_do_reset(host, SDHCI_RESET_CMD);
2714-
sdhci_do_reset(host, SDHCI_RESET_DATA);
2744+
sdhci_reset_for(host, TUNING_ABORT);
27152745

27162746
sdhci_end_tuning(host);
27172747

@@ -2979,8 +3009,7 @@ static void sdhci_card_event(struct mmc_host *mmc)
29793009
pr_err("%s: Resetting controller.\n",
29803010
mmc_hostname(mmc));
29813011

2982-
sdhci_do_reset(host, SDHCI_RESET_CMD);
2983-
sdhci_do_reset(host, SDHCI_RESET_DATA);
3012+
sdhci_reset_for(host, CARD_REMOVED);
29843013

29853014
sdhci_error_out_mrqs(host, -ENOMEDIUM);
29863015
}
@@ -3051,8 +3080,7 @@ static bool sdhci_request_done(struct sdhci_host *host)
30513080
/* This is to force an update */
30523081
host->ops->set_clock(host, host->clock);
30533082

3054-
sdhci_do_reset(host, SDHCI_RESET_CMD);
3055-
sdhci_do_reset(host, SDHCI_RESET_DATA);
3083+
sdhci_reset_for(host, REQUEST_ERROR);
30563084

30573085
host->pending_reset = false;
30583086
}
@@ -3876,10 +3904,8 @@ void sdhci_cqe_disable(struct mmc_host *mmc, bool recovery)
38763904

38773905
host->cqe_on = false;
38783906

3879-
if (recovery) {
3880-
sdhci_do_reset(host, SDHCI_RESET_CMD);
3881-
sdhci_do_reset(host, SDHCI_RESET_DATA);
3882-
}
3907+
if (recovery)
3908+
sdhci_reset_for(host, CQE_RECOVERY);
38833909

38843910
pr_debug("%s: sdhci: CQE off, IRQ mask %#x, IRQ status %#x\n",
38853911
mmc_hostname(mmc), host->ier,

0 commit comments

Comments
 (0)