2022-05-18 07:15:41

by Shaik Sajida Bhanu

[permalink] [raw]
Subject: [PATCH V6 4/5] mmc: debugfs: Add debug fs error state entry for mmc driver

Add debug fs entry error state to query eMMC and SD card errors statistics.
If any errors occurred in eMMC and SD card driver level then
err_state value will be set to 1.

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: Shaik Sajida Bhanu <[email protected]>
---
drivers/mmc/core/debugfs.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index 6aa5a60..3c7908d 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -223,6 +223,27 @@ static int mmc_clock_opt_set(void *data, u64 val)
DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
"%llu\n");

+static int mmc_err_state_get(void *data, u64 *val)
+{
+ struct mmc_host *host = data;
+ int i;
+
+ if (!host)
+ return -EINVAL;
+
+ *val = 0;
+ for (i = 0; i < MMC_ERR_MAX; i++) {
+ if (host->err_stats[i]) {
+ *val = 1;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(mmc_err_state, mmc_err_state_get, NULL, "%llu\n");
+
static int mmc_err_stats_show(struct seq_file *file, void *data)
{
struct mmc_host *host = (struct mmc_host *)file->private;
@@ -289,6 +310,8 @@ void mmc_add_host_debugfs(struct mmc_host *host)
debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host,
&mmc_clock_fops);

+ debugfs_create_file("err_state", 0600, root, host,
+ &mmc_err_state);
debugfs_create_file("err_stats", 0600, root, host,
&mmc_err_stats_fops);

--
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:21:31

by Adrian Hunter

[permalink] [raw]
Subject: Re: [PATCH V6 4/5] mmc: debugfs: Add debug fs error state entry for mmc driver

On 18/05/22 10:02, Shaik Sajida Bhanu wrote:
> Add debug fs entry error state to query eMMC and SD card errors statistics.
> If any errors occurred in eMMC and SD card driver level then
> err_state value will be set to 1.
>
> 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: Shaik Sajida Bhanu <[email protected]>

Could use debugfs_create_file_unsafe() (see below)

Otherwise:

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

> ---
> drivers/mmc/core/debugfs.c | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
> index 6aa5a60..3c7908d 100644
> --- a/drivers/mmc/core/debugfs.c
> +++ b/drivers/mmc/core/debugfs.c
> @@ -223,6 +223,27 @@ static int mmc_clock_opt_set(void *data, u64 val)
> DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
> "%llu\n");
>
> +static int mmc_err_state_get(void *data, u64 *val)
> +{
> + struct mmc_host *host = data;
> + int i;
> +
> + if (!host)
> + return -EINVAL;
> +
> + *val = 0;
> + for (i = 0; i < MMC_ERR_MAX; i++) {
> + if (host->err_stats[i]) {
> + *val = 1;
> + break;
> + }
> + }
> +
> + return 0;
> +}
> +
> +DEFINE_DEBUGFS_ATTRIBUTE(mmc_err_state, mmc_err_state_get, NULL, "%llu\n");
> +
> static int mmc_err_stats_show(struct seq_file *file, void *data)
> {
> struct mmc_host *host = (struct mmc_host *)file->private;
> @@ -289,6 +310,8 @@ void mmc_add_host_debugfs(struct mmc_host *host)
> debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host,
> &mmc_clock_fops);
>
> + debugfs_create_file("err_state", 0600, root, host,
> + &mmc_err_state);

This could use debugfs_create_file_unsafe()

> debugfs_create_file("err_stats", 0600, root, host,
> &mmc_err_stats_fops);
>


2022-05-24 07:50:16

by Shaik Sajida Bhanu

[permalink] [raw]
Subject: Re: [PATCH V6 4/5] mmc: debugfs: Add debug fs error state entry for mmc driver

Hi Adrian,

Thanks for the review.

Please find the inline comments.

Thanks,

Sajida

On 5/23/2022 12:45 PM, Adrian Hunter wrote:
> On 18/05/22 10:02, Shaik Sajida Bhanu wrote:
>> Add debug fs entry error state to query eMMC and SD card errors statistics.
>> If any errors occurred in eMMC and SD card driver level then
>> err_state value will be set to 1.
>>
>> 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: Shaik Sajida Bhanu <[email protected]>
> Could use debugfs_create_file_unsafe() (see below)
>
> Otherwise:
>
> Acked-by: Adrian Hunter <[email protected]>
Sure Thank you
>
>> ---
>> drivers/mmc/core/debugfs.c | 23 +++++++++++++++++++++++
>> 1 file changed, 23 insertions(+)
>>
>> diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
>> index 6aa5a60..3c7908d 100644
>> --- a/drivers/mmc/core/debugfs.c
>> +++ b/drivers/mmc/core/debugfs.c
>> @@ -223,6 +223,27 @@ static int mmc_clock_opt_set(void *data, u64 val)
>> DEFINE_DEBUGFS_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
>> "%llu\n");
>>
>> +static int mmc_err_state_get(void *data, u64 *val)
>> +{
>> + struct mmc_host *host = data;
>> + int i;
>> +
>> + if (!host)
>> + return -EINVAL;
>> +
>> + *val = 0;
>> + for (i = 0; i < MMC_ERR_MAX; i++) {
>> + if (host->err_stats[i]) {
>> + *val = 1;
>> + break;
>> + }
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +DEFINE_DEBUGFS_ATTRIBUTE(mmc_err_state, mmc_err_state_get, NULL, "%llu\n");
>> +
>> static int mmc_err_stats_show(struct seq_file *file, void *data)
>> {
>> struct mmc_host *host = (struct mmc_host *)file->private;
>> @@ -289,6 +310,8 @@ void mmc_add_host_debugfs(struct mmc_host *host)
>> debugfs_create_file_unsafe("clock", S_IRUSR | S_IWUSR, root, host,
>> &mmc_clock_fops);
>>
>> + debugfs_create_file("err_state", 0600, root, host,
>> + &mmc_err_state);
> This could use debugfs_create_file_unsafe()
Sure
>
>> debugfs_create_file("err_stats", 0600, root, host,
>> &mmc_err_stats_fops);
>>