2022-05-18 07:15:45

by Shaik Sajida Bhanu

[permalink] [raw]
Subject: [PATCH V6 0/5] mmc: add error statistics for eMMC and SD card

From: Rajeshwari Ravindra Kamble <[email protected]>

Changes since V5:
- Considered all error stats enums to set error state.
- Added missed tuning error related code changes which was
missed in patch set V5 as Adrain Hunter pointed.
- Replaced DEFINE_SIMPLE_ATTRIBUTE with DEFINE_DEBUGFS_ATTRIBUTE
as suggested by Adrain Hunter.

Changes since V4:
- Defined new macro to increment err_stats members when error occured
as suggested by Adrain Hunter.
- Called err_stats members increment function after printing the error
as suggested by Adrain Hunter.
- Considered INDEX and END_BIT errors same as CRC errors as suggested
by Adrain Hunter.
- Removed Null check for host in debug fs functions and Reordered
err_stats declarationas suggested by Adrain Hunter.
- Removed err_state variable stuff and updated err_state debug fs entry
based on the err_stats members state as suggested by Adrain Hunter.

Changes since V3:
- Dropped error stats feature flag as suggested by Adrain Hunter.
- Separated error state related changes in separate patches as
suggested by Adrain Hunter.
[PATCH V4 4/7] : error state debug fs
[PATCH V4 5/7] : error state enable function
[PATCH V4 6/7] : error state enable in error case
- Note: we are enabling error state before calling sdhci_dumpregs
we couldn't add the err state in error stats array as err state
is not error type.
- Corrected Signed-off-by order as suggested by Bjron Andersson.
- Moved error state enable code from sdhci_dumpregs to error
conditions as suggested by Adrain Hunter

Changes since V2:
- Removed userspace error stats clear debug fs entry as suggested
by Adrain Hunter.
- Split patch into 4 patches
[PATCH V3 1/4] : sdhci driver
[PATCH V3 2/4] : debug fs entries
[PATCH V3 3/4] : core driver
[PATCH V3 4/4] : cqhci driver
- Used for loop to print error messages instead of using printf
statements for all error messages as suggested by Adrain Hunter.
- Introduced one flag to enable error stats feature, if any other
client wants to use this feature, they need to enable that flag.
- Moved reset command timeout error statement to card init flow
as suggested by Adrain Hunter.

Changes since V1:
- Removed sysfs entry for eMMC and SD card error statistics and added
debugfs entry as suggested by Adrian Hunter and Ulf Hansson.

Shaik Sajida Bhanu (5):
mmc: core: Capture eMMC and SD card errors
mmc: sdhci: Capture eMMC and SD card errors
mmc: debugfs: Add debug fs entry for mmc driver
mmc: debugfs: Add debug fs error state entry for mmc driver
mmc: cqhci: Capture eMMC and SD card errors

drivers/mmc/core/core.c | 10 +++++-
drivers/mmc/core/debugfs.c | 79 +++++++++++++++++++++++++++++++++++++++++++
drivers/mmc/host/cqhci-core.c | 9 ++++-
drivers/mmc/host/sdhci.c | 59 ++++++++++++++++++++++++--------
drivers/mmc/host/sdhci.h | 3 ++
include/linux/mmc/host.h | 26 ++++++++++++++
include/linux/mmc/mmc.h | 6 ++++
7 files changed, 175 insertions(+), 17 deletions(-)

--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation



2022-05-18 07:15:47

by Shaik Sajida Bhanu

[permalink] [raw]
Subject: [PATCH V6 1/5] 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 <[email protected]>
Signed-off-by: Sayali Lokhande <[email protected]>
Signed-off-by: Bao D. Nguyen <[email protected]>
Signed-off-by: Ram Prakash Gupta <[email protected]>
Signed-off-by: Shaik Sajida Bhanu <[email protected]>
---
drivers/mmc/core/core.c | 10 +++++++++-
include/linux/mmc/host.h | 26 ++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 368f104..5db5adf 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -943,9 +943,11 @@ int mmc_execute_tuning(struct mmc_card *card)
}

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

return err;
}
@@ -2242,6 +2244,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 0c0c9a0..0d7c0f7 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -93,6 +93,25 @@ 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_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
@@ -498,6 +517,7 @@ struct mmc_host {
/* Host Software Queue support */
bool hsq_enabled;

+ u32 err_stats[MMC_ERR_MAX];
unsigned long private[] ____cacheline_aligned;
};

@@ -632,6 +652,12 @@ 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);

--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


2022-05-23 08:20:38

by Adrian Hunter

[permalink] [raw]
Subject: Re: [PATCH V6 1/5] mmc: core: Capture eMMC and SD card errors

On 18/05/22 10:02, 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 <[email protected]>
> Signed-off-by: Sayali Lokhande <[email protected]>
> Signed-off-by: Bao D. Nguyen <[email protected]>
> Signed-off-by: Ram Prakash Gupta <[email protected]>
> Signed-off-by: Shaik Sajida Bhanu <[email protected]>

Seems to need to be re-based on Ulf's next branch:

git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next

Otherwise:

Acked-by: Adrian Hunter <[email protected]>

> ---
> drivers/mmc/core/core.c | 10 +++++++++-
> include/linux/mmc/host.h | 26 ++++++++++++++++++++++++++
> 2 files changed, 35 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 368f104..5db5adf 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -943,9 +943,11 @@ int mmc_execute_tuning(struct mmc_card *card)
> }
>
> /* Only print error when we don't check for card removal */
> - if (!host->detect_change)
> + if (!host->detect_change) {
> pr_err("%s: tuning execution failed: %d\n",
> mmc_hostname(host), err);
> + mmc_debugfs_err_stats_inc(host, MMC_ERR_TUNING);
> + }
>
> return err;
> }
> @@ -2242,6 +2244,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 0c0c9a0..0d7c0f7 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -93,6 +93,25 @@ 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_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
> @@ -498,6 +517,7 @@ struct mmc_host {
> /* Host Software Queue support */
> bool hsq_enabled;
>
> + u32 err_stats[MMC_ERR_MAX];
> unsigned long private[] ____cacheline_aligned;
> };
>
> @@ -632,6 +652,12 @@ 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);
>


2022-05-24 18:59:53

by Shaik Sajida Bhanu

[permalink] [raw]
Subject: Re: [PATCH V6 1/5] mmc: core: Capture eMMC and SD card errors

On 5/23/2022 12:44 PM, Adrian Hunter wrote:
> On 18/05/22 10:02, 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 <[email protected]>
>> Signed-off-by: Sayali Lokhande <[email protected]>
>> Signed-off-by: Bao D. Nguyen <[email protected]>
>> Signed-off-by: Ram Prakash Gupta <[email protected]>
>> Signed-off-by: Shaik Sajida Bhanu <[email protected]>
> Seems to need to be re-based on Ulf's next branch:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git next
Sure Thank You for the review.
>
> Otherwise:
>
> Acked-by: Adrian Hunter <[email protected]>
>
>> ---
>> drivers/mmc/core/core.c | 10 +++++++++-
>> include/linux/mmc/host.h | 26 ++++++++++++++++++++++++++
>> 2 files changed, 35 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>> index 368f104..5db5adf 100644
>> --- a/drivers/mmc/core/core.c
>> +++ b/drivers/mmc/core/core.c
>> @@ -943,9 +943,11 @@ int mmc_execute_tuning(struct mmc_card *card)
>> }
>>
>> /* Only print error when we don't check for card removal */
>> - if (!host->detect_change)
>> + if (!host->detect_change) {
>> pr_err("%s: tuning execution failed: %d\n",
>> mmc_hostname(host), err);
>> + mmc_debugfs_err_stats_inc(host, MMC_ERR_TUNING);
>> + }
>>
>> return err;
>> }
>> @@ -2242,6 +2244,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 0c0c9a0..0d7c0f7 100644
>> --- a/include/linux/mmc/host.h
>> +++ b/include/linux/mmc/host.h
>> @@ -93,6 +93,25 @@ 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_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
>> @@ -498,6 +517,7 @@ struct mmc_host {
>> /* Host Software Queue support */
>> bool hsq_enabled;
>>
>> + u32 err_stats[MMC_ERR_MAX];
>> unsigned long private[] ____cacheline_aligned;
>> };
>>
>> @@ -632,6 +652,12 @@ 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);
>>