lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1653481701-19642-2-git-send-email-quic_c_sbhanu@quicinc.com>
Date:   Wed, 25 May 2022 17:58:18 +0530
From:   Shaik Sajida Bhanu <quic_c_sbhanu@...cinc.com>
To:     adrian.hunter@...el.com, ulf.hansson@...aro.org, agross@...nel.org,
        bjorn.andersson@...aro.org, p.zabel@...gutronix.de,
        chris@...ntf.net, venkatg@...eaurora.org, gdjakov@...sol.com,
        quic_asutoshd@...cinc.com
Cc:     linux-arm-msm@...r.kernel.org, linux-mmc@...r.kernel.org,
        linux-kernel@...r.kernel.org, quic_rampraka@...cinc.com,
        quic_pragalla@...cinc.com, quic_sartgarg@...cinc.com,
        quic_nitirawa@...cinc.com, quic_sayalil@...cinc.com,
        Shaik Sajida Bhanu <quic_c_sbhanu@...cinc.com>,
        Liangliang Lu <quic_luliang@...cinc.com>,
        "Bao D . Nguyen" <quic_nguyenb@...cinc.com>
Subject: [PATCH V7 1/4] 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@...cinc.com>
Signed-off-by: Sayali Lokhande <quic_sayalil@...cinc.com>
Signed-off-by: Bao D. Nguyen <quic_nguyenb@...cinc.com>
Signed-off-by: Ram Prakash Gupta <quic_rampraka@...cinc.com>
Signed-off-by: Shaik Sajida Bhanu <quic_c_sbhanu@...cinc.com>
Acked-by: Adrian Hunter <adrian.hunter@...el.com>
---
 drivers/mmc/core/core.c  | 11 +++++++++--
 include/linux/mmc/host.h | 26 ++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 2553d90..ede7887 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1171,10 +1171,11 @@ int mmc_execute_tuning(struct mmc_card *card)
 
 	err = host->ops->execute_tuning(host, opcode);
 
-	if (err)
+	if (err) {
 		pr_err("%s: tuning execution failed: %d\n",
 			mmc_hostname(host), err);
-	else
+		mmc_debugfs_err_stats_inc(host, MMC_ERR_TUNING);
+	} else
 		mmc_retune_enable(host);
 
 	return err;
@@ -2811,6 +2812,12 @@ void mmc_rescan(struct work_struct *work)
 		if (freqs[i] <= host->f_min)
 			break;
 	}
+
+	/*
+	 * Ignore the command timeout errors observed during
+	 * the card init as those are excepted.
+	 */
+	host->err_stats[MMC_ERR_CMD_TIMEOUT] = 0;
 	mmc_release_host(host);
 
  out:
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 0b24394..ceb353b 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -82,6 +82,25 @@ struct mmc_ios {
 	bool enhanced_strobe;			/* hs400es selection */
 };
 
+enum mmc_err_stat {
+	MMC_ERR_CMD_TIMEOUT,
+	MMC_ERR_CMD_CRC,
+	MMC_ERR_DAT_TIMEOUT,
+	MMC_ERR_DAT_CRC,
+	MMC_ERR_AUTO_CMD,
+	MMC_ERR_ADMA,
+	MMC_ERR_TUNING,
+	MMC_ERR_CMDQ_RED,
+	MMC_ERR_CMDQ_GCE,
+	MMC_ERR_CMDQ_ICCE,
+	MMC_ERR_REQ_TIMEOUT,
+	MMC_ERR_CMDQ_REQ_TIMEOUT,
+	MMC_ERR_ICE_CFG,
+	MMC_ERR_CTRL_TIMEOUT,
+	MMC_ERR_UNEXPECTED_IRQ,
+	MMC_ERR_MAX,
+};
+
 struct mmc_host_ops {
 	/*
 	 * It is optional for the host to implement pre_req and post_req in
@@ -397,6 +416,7 @@ struct mmc_host {
 	int			dsr_req;	/* DSR value is valid */
 	u32			dsr;	/* optional driver stage (DSR) value */
 
+	u32			err_stats[MMC_ERR_MAX];
 	unsigned long		private[0] ____cacheline_aligned;
 };
 
@@ -546,6 +566,12 @@ static inline void mmc_retune_recheck(struct mmc_host *host)
 		host->retune_now = 1;
 }
 
+static inline void mmc_debugfs_err_stats_inc(struct mmc_host *host,
+					     enum mmc_err_stat stat)
+{
+	host->err_stats[stat] += 1;
+}
+
 void mmc_retune_pause(struct mmc_host *host);
 void mmc_retune_unpause(struct mmc_host *host);
 
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ