8000 mmc: core: Capture eMMC and SD card errors · raspberrypi/linux@91f059c · GitHub
[go: up one dir, main page]

Skip to content

Commit 91f059c

Browse files
Shaik Sajida Bhanustorulf
authored andcommitted
mmc: core: Capture eMMC and SD card errors
Add changes to capture eMMC and SD card errors. This is useful for debug and testing. Signed-off-by: Liangliang Lu <quic_luliang@quicinc.com> Signed-off-by: Sayali Lokhande <quic_sayalil@quicinc.com> Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com> Signed-off-by: Ram Prakash Gupta <quic_rampraka@quicinc.com> Signed-off-by: Shaik Sajida Bhanu <quic_c_sbhanu@quicinc.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Link: https://lore.kernel.org/r/1653674036-21829-2-git-send-email-quic_c_sbhanu@quicinc.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent f0c88b0 commit 91f059c

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

drivers/mmc/core/core.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,9 +943,11 @@ int mmc_execute_tuning(struct mmc_card *card)
943943
}
944944

945945
/* Only print error when we don't check for card removal */
946-
if (!host->detect_change)
946+
if (!host->detect_change) {
947947
pr_err("%s: tuning execution failed: %d\n",
948948
mmc_hostname(host), err);
949+
mmc_debugfs_err_stats_inc(host, MMC_ERR_TUNING);
950+
}
949951

950952
return err;
951953
}
@@ -2244,6 +2246,12 @@ void mmc_rescan(struct work_struct *work)
22442246
if (freqs[i] <= host->f_min)
22452247
break;
22462248
}
2249+
2250+
/*
2251+
* Ignore the command timeout errors observed during
2252+
* the card init as those are excepted.
2253+
*/
2254+
host->err_stats[MMC_ERR_CMD_TIMEOUT] = 0;
22472255
mmc_release_host(host);
22482256

22492257
out:

include/linux/mmc/host.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ struct mmc_clk_phase_map {
9393

9494
struct mmc_host;
9595

96+
enum mmc_err_stat {
97+
MMC_ERR_CMD_TIMEOUT,
98+
MMC_ERR_CMD_CRC,
99+
MMC_ERR_DAT_TIMEOUT,
100+
MMC_ERR_DAT_CRC,
101+
MMC_ERR_AUTO_CMD,
102+
MMC_ERR_ADMA,
103+
MMC_ERR_TUNING,
104+
MMC_ERR_CMDQ_RED,
105+
MMC_ERR_CMDQ_GCE,
106+
MMC_ERR_CMDQ_ICCE,
107+
MMC_ERR_REQ_TIMEOUT,
108+
MMC_ERR_CMDQ_REQ_TIMEOUT,
109+
MMC_ERR_ICE_CFG,
110+
MMC_ERR_CTRL_TIMEOUT,
111+
MMC_ERR_UNEXPECTED_IRQ,
112+
MMC_ERR_MAX,
113+
};
114+
96115
struct mmc_host_ops {
97116
/*
98117
* It is optional for the host to implement pre_req and post_req in
@@ -501,6 +520,7 @@ struct mmc_host {
501520
/* Host Software Queue support */
502521
bool hsq_enabled;
503522

523+
u32 err_stats[MMC_ERR_MAX];
504524
unsigned long private[] ____cacheline_aligned;
505525
};
506526

@@ -635,6 +655,12 @@ static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data)
635655
return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
636656
}
637657

658+
static inline void mmc_debugfs_err_stats_inc(struct mmc_host *host,
659+
enum mmc_err_stat stat)
660+
{
661+
host->err_stats[stat] += 1;
662+
}
663+
638664
int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
639665
int mmc_send_abort_tuning(struct mmc_host *host, u32 opcode);
640666
int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd);

0 commit comments

Comments
 (0)
0