From patchwork Tue Feb 14 20:53:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9572857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E8FE1601E7 for ; Tue, 14 Feb 2017 20:53:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6C7426C9B for ; Tue, 14 Feb 2017 20:53:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA5902840E; Tue, 14 Feb 2017 20:53:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E88C26C9B for ; Tue, 14 Feb 2017 20:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752677AbdBNUxb (ORCPT ); Tue, 14 Feb 2017 15:53:31 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35858 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751941AbdBNUxb (ORCPT ); Tue, 14 Feb 2017 15:53:31 -0500 Received: by mail-wr0-f194.google.com with SMTP id k90so28891548wrc.3 for ; Tue, 14 Feb 2017 12:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=pW5VBxrpd/V+nZlGf1/dzpjm4ctRzbI5j6QINtxxwQo=; b=U9fNNAv1ehKe4FNgDUR5ccUkuej1tOOw+jZNUSd2c6gbxdNZXWbFz/yTN+D4uz0Yye Hf2V5D8RnGbq1jifFKDhFxUfeR0ZFFQUUZ2QWK8iPhc9cX0TAkXqtWjspoPyEJWRv51a Bo3hjOCQYVsufmKGimap/+PAcZha24wjtdJE48yuG10aaT13QKghtPAqc7XOoGNqQHbd 0FoemNF9LnkAr/qu0BfQyuGOYyo6UgsrXZS+se9aVzf4uzZt4WuUbBa5N0YErSaVY1Bk KNrIE6Sjx/a4tXvx8s58HEsYAjOSxwLB+1ScrKOQnk4A2bLD2vrF25KbviPPO9dofC2/ UBBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=pW5VBxrpd/V+nZlGf1/dzpjm4ctRzbI5j6QINtxxwQo=; b=PLoc3btDBcWb3K6BeCsfjH2mpXbHRuG/XoOW7jXEOt+ZAoztQO3f86Z9WZXg4mciOd 2iTt8cjXCgU1LRoZIheTNreaHSfPfY1yjOvlMKmNcYCq18tR3ihY12dstaDq40nku20v KSIzDvqJ7RJr8bOihiWJQDhUqV6HQIezdrq4DJQR0F5xdyIkcfVz5o+jh7mR/hv2NE7+ Bu4gVfpxL1MjwF1pTNS4+3oC+BPmf4g1s74BMH76DJamIfXyrBPKzUUY9v2zLOxGWcKB Va066pWfN90kL+nifKIfGkKAlu9wKMAHQYSwgOMRC2tO9fHSbVbVx4BWdII0D0DLJtBP WPlg== X-Gm-Message-State: AMke39lyBdLewLCDXOl8pzl8s6p2AIHtv3MoiaMXknHQ1zIgKN4YChnLQEE1uQ2O+Og3mA== X-Received: by 10.223.169.140 with SMTP id b12mr26951032wrd.138.1487105609715; Tue, 14 Feb 2017 12:53:29 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:9533:a20:55f1:fb4b? (p200300C6EBDC400095330A2055F1FB4B.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:9533:a20:55f1:fb4b]) by smtp.googlemail.com with ESMTPSA id 10sm4869167wmi.23.2017.02.14.12.53.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Feb 2017 12:53:29 -0800 (PST) To: Ulf Hansson , "linux-mmc@vger.kernel.org" Cc: Jungseung Lee From: Heiner Kallweit Subject: [PATCH] mmc: core: use eMMC lifetime info to warn user Message-ID: Date: Tue, 14 Feb 2017 21:53:21 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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