diff mbox series

[V4,1/7] mmc: core: Capture eMMC and SD card errors

Message ID 1646226227-32429-2-git-send-email-quic_c_sbhanu@quicinc.com
State Superseded
Headers show
Series mmc: add error statistics for eMMC and SD card | expand

Commit Message

Shaik Sajida Bhanu March 2, 2022, 1:03 p.m. UTC
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>
---
 drivers/mmc/core/core.c  |  6 ++++++
 include/linux/mmc/host.h | 23 +++++++++++++++++++++++
 2 files changed, 29 insertions(+)

Comments

Adrian Hunter March 8, 2022, 9:44 a.m. UTC | #1
On 2.3.2022 15.03, Shaik Sajida Bhanu wrote:
> 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>
> ---
>  drivers/mmc/core/core.c  |  6 ++++++
>  include/linux/mmc/host.h | 23 +++++++++++++++++++++++
>  2 files changed, 29 insertions(+)
> 
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 368f104..f3679ed 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2242,6 +2242,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 7afb57c..3b7f1e5 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -93,6 +93,23 @@ struct mmc_clk_phase_map {
>  
>  struct mmc_host;
>  
> +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_MAX,
> +};
> +
>  struct mmc_host_ops {
>  	/*
>  	 * It is optional for the host to implement pre_req and post_req in
> @@ -500,6 +517,7 @@ struct mmc_host {
>  
>  	/* Host Software Queue support */
>  	bool			hsq_enabled;
> +	u32                     err_stats[MMC_ERR_MAX];

This makes it look like err_stats has something to do with Host Software Queue.
Perhaps move it to be with debugfs_root. Also use tabs not spaces

	struct dentry		*debugfs_root;
	u32			err_stats[MMC_ERR_MAX];

>  
>  	unsigned long		private[] ____cacheline_aligned;
>  };
> @@ -635,6 +653,11 @@ static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data)
>  	return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
>  }
>  
> +static inline void mmc_debugfs_err_stats_inc(struct mmc_host *host,
> +		enum mmc_err_stat stat) {
> +	host->err_stats[stat] += 1;
> +}
> +
>  int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
>  int mmc_send_abort_tuning(struct mmc_host *host, u32 opcode);
>  int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd);
Shaik Sajida Bhanu March 12, 2022, 5:59 p.m. UTC | #2
Hi,

Thanks for the review.

Please find the inline comments.

Thanks,
Sajida
> -----Original Message-----
> From: Adrian Hunter <adrian.hunter@intel.com>
> Sent: Tuesday, March 8, 2022 3:15 PM
> To: Sajida Bhanu (Temp) (QUIC) <quic_c_sbhanu@quicinc.com>;
> quic_riteshh@quicinc.com; Asutosh Das (asd) <asutoshd@quicinc.com>;
> ulf.hansson@linaro.org; agross@kernel.org; bjorn.andersson@linaro.org;
> linux-mmc@vger.kernel.org; linux-arm-msm@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Cc: Veerabhadrarao Badiganti (QUIC) <quic_vbadigan@quicinc.com>; Ram
> Prakash Gupta (QUIC) <quic_rampraka@quicinc.com>; Pradeep Pragallapati
> (QUIC) <quic_pragalla@quicinc.com>; Sarthak Garg (QUIC)
> <quic_sartgarg@quicinc.com>; Nitin Rawat (QUIC)
> <quic_nitirawa@quicinc.com>; Sayali Lokhande (QUIC)
> <quic_sayalil@quicinc.com>; Liangliang Lu <quic_luliang@quicinc.com>;
> quic_nguyenb <quic_nguyenb@quicinc.com>
> Subject: Re: [PATCH V4 1/7] mmc: core: Capture eMMC and SD card errors
> 
> On 2.3.2022 15.03, Shaik Sajida Bhanu wrote:
> > 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>
> > ---
> >  drivers/mmc/core/core.c  |  6 ++++++
> >  include/linux/mmc/host.h | 23 +++++++++++++++++++++++
> >  2 files changed, 29 insertions(+)
> >
> > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index
> > 368f104..f3679ed 100644
> > --- a/drivers/mmc/core/core.c
> > +++ b/drivers/mmc/core/core.c
> > @@ -2242,6 +2242,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
> > 7afb57c..3b7f1e5 100644
> > --- a/include/linux/mmc/host.h
> > +++ b/include/linux/mmc/host.h
> > @@ -93,6 +93,23 @@ struct mmc_clk_phase_map {
> >
> >  struct mmc_host;
> >
> > +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_MAX,
> > +};
> > +
> >  struct mmc_host_ops {
> >  	/*
> >  	 * It is optional for the host to implement pre_req and post_req in
> > @@ -500,6 +517,7 @@ struct mmc_host {
> >
> >  	/* Host Software Queue support */
> >  	bool			hsq_enabled;
> > +	u32                     err_stats[MMC_ERR_MAX];
> 
> This makes it look like err_stats has something to do with Host Software
> Queue.
> Perhaps move it to be with debugfs_root. Also use tabs not spaces
> 
> 	struct dentry		*debugfs_root;
> 	u32			err_stats[MMC_ERR_MAX];
> 
Sure will move
> >
> >  	unsigned long		private[] ____cacheline_aligned;
> >  };
> > @@ -635,6 +653,11 @@ static inline enum dma_data_direction
> mmc_get_dma_dir(struct mmc_data *data)
> >  	return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE :
> > DMA_FROM_DEVICE;  }
> >
> > +static inline void mmc_debugfs_err_stats_inc(struct mmc_host *host,
> > +		enum mmc_err_stat stat) {
> > +	host->err_stats[stat] += 1;
> > +}
> > +
> >  int mmc_send_tuning(struct mmc_host *host, u32 opcode, int
> > *cmd_error);  int mmc_send_abort_tuning(struct mmc_host *host, u32
> > opcode);  int mmc_get_ext_csd(struct mmc_card *card, u8
> **new_ext_csd);
diff mbox series

Patch

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 368f104..f3679ed 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2242,6 +2242,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 7afb57c..3b7f1e5 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -93,6 +93,23 @@  struct mmc_clk_phase_map {
 
 struct mmc_host;
 
+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_MAX,
+};
+
 struct mmc_host_ops {
 	/*
 	 * It is optional for the host to implement pre_req and post_req in
@@ -500,6 +517,7 @@  struct mmc_host {
 
 	/* Host Software Queue support */
 	bool			hsq_enabled;
+	u32                     err_stats[MMC_ERR_MAX];
 
 	unsigned long		private[] ____cacheline_aligned;
 };
@@ -635,6 +653,11 @@  static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data)
 	return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
 }
 
+static inline void mmc_debugfs_err_stats_inc(struct mmc_host *host,
+		enum mmc_err_stat stat) {
+	host->err_stats[stat] += 1;
+}
+
 int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
 int mmc_send_abort_tuning(struct mmc_host *host, u32 opcode);
 int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd);