All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gwendal Grignou <gwendal@chromium.org>
To: ulf.hansson@linaro.org, Alex.Lemberg@sandisk.com,
	avi.shchislowski@sandisk.com, yaniv.agman@sandisk.com,
	holgerschurig@gmail.com, chris@printf.net,
	baolin.wang@linaro.org
Cc: linux-mmc@vger.kernel.org
Subject: [PATCH 1/6] mmc: core: in _init, exclude FW revision from CID check.
Date: Wed, 13 Apr 2016 15:33:39 -0700	[thread overview]
Message-ID: <1460586824-40688-2-git-send-email-gwendal@chromium.org> (raw)
In-Reply-To: <1460586824-40688-1-git-send-email-gwendal@chromium.org>

In mmc_card_init() when we reset a card we check the newly found
card is indeed the previous card by comparing the CID.
If the firmware is upgraded, we need to exclude the Product Revision,
it can change if the firmware is upgraded.

Reviewed-by: Puthikorn Voravootivat <puthik@chromium.org>
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
 drivers/mmc/core/mmc.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e37ab34..4fe3208 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1406,12 +1406,24 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 		goto err;
 
 	if (oldcard) {
-		if (memcmp(cid, oldcard->raw_cid, sizeof(cid)) != 0) {
+		/*
+		 * When comparing the CID, we should exclude the product
+		 * revision (Field PRV, offset 55:48), because it can change if
+		 * the firmware is upgraded. The new CRC can then be different.
+		 * Therefore we test if offset 8 - 48 and 128 - 56 are checked.
+		 */
+		if ((cid[0] != oldcard->raw_cid[0]) ||
+		    (cid[1] != oldcard->raw_cid[1]) ||
+		    ((cid[2] & 0xFF00FFFF) !=
+		     (oldcard->raw_cid[2] & 0xFF00FFFF)) ||
+		    ((cid[3] & 0xFFFFFF00) !=
+		     (oldcard->raw_cid[3] & 0xFFFFFF00))) {
 			err = -ENOENT;
 			goto err;
 		}
 
 		card = oldcard;
+		memcpy(card->raw_cid, cid, sizeof(cid));
 	} else {
 		/*
 		 * Allocate card structure.
@@ -1456,10 +1468,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 		err = mmc_decode_csd(card);
 		if (err)
 			goto free_card;
-		err = mmc_decode_cid(card);
-		if (err)
-			goto free_card;
 	}
+	err = mmc_decode_cid(card);
+	if (err)
+		goto free_card;
 
 	/*
 	 * handling only for cards supporting DSR and hosts requesting
-- 
2.8.0.rc3.226.g39d4020


  reply	other threads:[~2016-04-13 22:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13 22:33 [PATCH 0/6] mmc: Add in-kernel firmware upgrade support Gwendal Grignou
2016-04-13 22:33 ` Gwendal Grignou [this message]
2016-04-13 22:33 ` [PATCH 2/6] mmc: core: resecan [EXT_]CSD at card init Gwendal Grignou
2016-04-13 22:33 ` [PATCH 3/6] FROMLIST: mmc: core: Support FFU for eMMC v5.0 Gwendal Grignou
2016-04-14  8:48   ` Ulf Hansson
2016-04-13 22:33 ` [PATCH 4/6] mmc: add FFU support to card/block.c Gwendal Grignou
2016-04-13 23:10   ` kbuild test robot
2016-04-13 22:33 ` [PATCH 5/6] mmc: ffu: Hack for Hynix eMMC Gwendal Grignou
2016-04-13 22:33 ` [PATCH 6/6] mmc: ffu: Hack for Samsung part Gwendal Grignou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460586824-40688-2-git-send-email-gwendal@chromium.org \
    --to=gwendal@chromium.org \
    --cc=Alex.Lemberg@sandisk.com \
    --cc=avi.shchislowski@sandisk.com \
    --cc=baolin.wang@linaro.org \
    --cc=chris@printf.net \
    --cc=holgerschurig@gmail.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=yaniv.agman@sandisk.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.