diff mbox

mmc: core: use eMMC lifetime info to warn user

Message ID b3f67c2a-fbf7-b2fb-c05e-138fbdd77e39@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Heiner Kallweit Feb. 14, 2017, 8:53 p.m. UTC
Now that the new lifetime parameters are available in struct mmc_ext_csd
we can use this information to warn the user if card is close to or
beyond end of its lifetime.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/mmc/core/bus.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Jaehoon Chung Feb. 15, 2017, 3:39 a.m. UTC | #1
Hi,

On 02/15/2017 05:53 AM, Heiner Kallweit wrote:
> Now that the new lifetime parameters are available in struct mmc_ext_csd
> we can use this information to warn the user if card is close to or
> beyond end of its lifetime.

I don't know this patch has which benefit to user.
I think it doesn't need to show the life time in kernel side.

Best Regards,
Jaehoon Chung

> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/mmc/core/bus.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
> index 30124651..ab20d242 100644
> --- a/drivers/mmc/core/bus.c
> +++ b/drivers/mmc/core/bus.c
> @@ -345,6 +345,22 @@ int mmc_add_card(struct mmc_card *card)
>  			uhs_bus_speed_mode, type, card->rca);
>  	}
>  
> +	if (card->ext_csd.device_life_time_est_typ_a == 0xb ||
> +	    card->ext_csd.device_life_time_est_typ_b == 0xb)
> +		pr_err("%s: memory has exceeded its life time",
> +			mmc_hostname(card->host));
> +	else if (card->ext_csd.device_life_time_est_typ_a == 0xa ||
> +		 card->ext_csd.device_life_time_est_typ_b == 0xa)
> +		pr_warn("%s: memory has used more than 90%% of its life time\n",
> +			mmc_hostname(card->host));
> +
> +	if (card->ext_csd.pre_eol_info == 3)
> +		pr_err("%s: out of reserved blocks\n",
> +			mmc_hostname(card->host));
> +	else if (card->ext_csd.pre_eol_info == 2)
> +		pr_warn("%s: more than 80%% of reserved blocks consumed\n",
> +			mmc_hostname(card->host));
> +
>  #ifdef CONFIG_DEBUG_FS
>  	mmc_add_card_debugfs(card);
>  #endif
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Shawn Lin Feb. 15, 2017, 7:04 a.m. UTC | #2
Hi Heiner,

On 2017/2/15 4:53, Heiner Kallweit wrote:
> Now that the new lifetime parameters are available in struct mmc_ext_csd
> we can use this information to warn the user if card is close to or
> beyond end of its lifetime.
>

This is really the user end argument that they could get it either from
sysfs or whether user-space tools. I don't believe the user would look
into the log but I assume you just add this for developers...

> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/mmc/core/bus.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
> index 30124651..ab20d242 100644
> --- a/drivers/mmc/core/bus.c
> +++ b/drivers/mmc/core/bus.c
> @@ -345,6 +345,22 @@ int mmc_add_card(struct mmc_card *card)
>  			uhs_bus_speed_mode, type, card->rca);
>  	}
>
> +	if (card->ext_csd.device_life_time_est_typ_a == 0xb ||
> +	    card->ext_csd.device_life_time_est_typ_b == 0xb)
> +		pr_err("%s: memory has exceeded its life time",
> +			mmc_hostname(card->host));
> +	else if (card->ext_csd.device_life_time_est_typ_a == 0xa ||
> +		 card->ext_csd.device_life_time_est_typ_b == 0xa)
> +		pr_warn("%s: memory has used more than 90%% of its life time\n",
> +			mmc_hostname(card->host));
> +
> +	if (card->ext_csd.pre_eol_info == 3)
> +		pr_err("%s: out of reserved blocks\n",
> +			mmc_hostname(card->host));
> +	else if (card->ext_csd.pre_eol_info == 2)
> +		pr_warn("%s: more than 80%% of reserved blocks consumed\n",
> +			mmc_hostname(card->host));
> +
>  #ifdef CONFIG_DEBUG_FS
>  	mmc_add_card_debugfs(card);
>  #endif
>

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Heiner Kallweit Feb. 15, 2017, 5:33 p.m. UTC | #3
Am 15.02.2017 um 08:04 schrieb Shawn Lin:
> Hi Heiner,
> 
> On 2017/2/15 4:53, Heiner Kallweit wrote:
>> Now that the new lifetime parameters are available in struct mmc_ext_csd
>> we can use this information to warn the user if card is close to or
>> beyond end of its lifetime.
>>
> 
> This is really the user end argument that they could get it either from
> sysfs or whether user-space tools. I don't believe the user would look
> into the log but I assume you just add this for developers...
> 
Indeed it's something userspace tools should take care of.
However I'm not aware of any standard tools doing this (especially on
non-production systems), so I thought such a sysylog warning would be
a good idea.
But of course there might be other opinions on that.

>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>>  drivers/mmc/core/bus.c | 16 ++++++++++++++++
>>  1 file changed, 16 insertions(+)
>>
>> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
>> index 30124651..ab20d242 100644
>> --- a/drivers/mmc/core/bus.c
>> +++ b/drivers/mmc/core/bus.c
>> @@ -345,6 +345,22 @@ int mmc_add_card(struct mmc_card *card)
>>              uhs_bus_speed_mode, type, card->rca);
>>      }
>>
>> +    if (card->ext_csd.device_life_time_est_typ_a == 0xb ||
>> +        card->ext_csd.device_life_time_est_typ_b == 0xb)
>> +        pr_err("%s: memory has exceeded its life time",
>> +            mmc_hostname(card->host));
>> +    else if (card->ext_csd.device_life_time_est_typ_a == 0xa ||
>> +         card->ext_csd.device_life_time_est_typ_b == 0xa)
>> +        pr_warn("%s: memory has used more than 90%% of its life time\n",
>> +            mmc_hostname(card->host));
>> +
>> +    if (card->ext_csd.pre_eol_info == 3)
>> +        pr_err("%s: out of reserved blocks\n",
>> +            mmc_hostname(card->host));
>> +    else if (card->ext_csd.pre_eol_info == 2)
>> +        pr_warn("%s: more than 80%% of reserved blocks consumed\n",
>> +            mmc_hostname(card->host));
>> +
>>  #ifdef CONFIG_DEBUG_FS
>>      mmc_add_card_debugfs(card);
>>  #endif
>>
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Shawn Lin Feb. 16, 2017, 2:21 a.m. UTC | #4
Hi

On 2017/2/16 1:33, Heiner Kallweit wrote:
> Am 15.02.2017 um 08:04 schrieb Shawn Lin:
>> Hi Heiner,
>>
>> On 2017/2/15 4:53, Heiner Kallweit wrote:
>>> Now that the new lifetime parameters are available in struct mmc_ext_csd
>>> we can use this information to warn the user if card is close to or
>>> beyond end of its lifetime.
>>>
>>
>> This is really the user end argument that they could get it either from
>> sysfs or whether user-space tools. I don't believe the user would look
>> into the log but I assume you just add this for developers...
>>
> Indeed it's something userspace tools should take care of.
> However I'm not aware of any standard tools doing this (especially on
> non-production systems), so I thought such a sysylog warning would be
> a good idea.


Usually we use mmc-utils and you could upstream your command to get
cards'lifetime there.

git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc-utils.git

> But of course there might be other opinions on that.
>
>>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>>> ---
>>>  drivers/mmc/core/bus.c | 16 ++++++++++++++++
>>>  1 file changed, 16 insertions(+)
>>>
>>> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
>>> index 30124651..ab20d242 100644
>>> --- a/drivers/mmc/core/bus.c
>>> +++ b/drivers/mmc/core/bus.c
>>> @@ -345,6 +345,22 @@ int mmc_add_card(struct mmc_card *card)
>>>              uhs_bus_speed_mode, type, card->rca);
>>>      }
>>>
>>> +    if (card->ext_csd.device_life_time_est_typ_a == 0xb ||
>>> +        card->ext_csd.device_life_time_est_typ_b == 0xb)
>>> +        pr_err("%s: memory has exceeded its life time",
>>> +            mmc_hostname(card->host));
>>> +    else if (card->ext_csd.device_life_time_est_typ_a == 0xa ||
>>> +         card->ext_csd.device_life_time_est_typ_b == 0xa)
>>> +        pr_warn("%s: memory has used more than 90%% of its life time\n",
>>> +            mmc_hostname(card->host));
>>> +
>>> +    if (card->ext_csd.pre_eol_info == 3)
>>> +        pr_err("%s: out of reserved blocks\n",
>>> +            mmc_hostname(card->host));
>>> +    else if (card->ext_csd.pre_eol_info == 2)
>>> +        pr_warn("%s: more than 80%% of reserved blocks consumed\n",
>>> +            mmc_hostname(card->host));
>>> +
>>>  #ifdef CONFIG_DEBUG_FS
>>>      mmc_add_card_debugfs(card);
>>>  #endif
>>>
>>
>>
>
>
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 30124651..ab20d242 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -345,6 +345,22 @@  int mmc_add_card(struct mmc_card *card)
 			uhs_bus_speed_mode, type, card->rca);
 	}
 
+	if (card->ext_csd.device_life_time_est_typ_a == 0xb ||
+	    card->ext_csd.device_life_time_est_typ_b == 0xb)
+		pr_err("%s: memory has exceeded its life time",
+			mmc_hostname(card->host));
+	else if (card->ext_csd.device_life_time_est_typ_a == 0xa ||
+		 card->ext_csd.device_life_time_est_typ_b == 0xa)
+		pr_warn("%s: memory has used more than 90%% of its life time\n",
+			mmc_hostname(card->host));
+
+	if (card->ext_csd.pre_eol_info == 3)
+		pr_err("%s: out of reserved blocks\n",
+			mmc_hostname(card->host));
+	else if (card->ext_csd.pre_eol_info == 2)
+		pr_warn("%s: more than 80%% of reserved blocks consumed\n",
+			mmc_hostname(card->host));
+
 #ifdef CONFIG_DEBUG_FS
 	mmc_add_card_debugfs(card);
 #endif