From patchwork Wed Apr 13 22:33:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwendal Grignou X-Patchwork-Id: 8829581 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 70088C0553 for ; Wed, 13 Apr 2016 22:34:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8625F20373 for ; Wed, 13 Apr 2016 22:34:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 893E520357 for ; Wed, 13 Apr 2016 22:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754333AbcDMWeR (ORCPT ); Wed, 13 Apr 2016 18:34:17 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:35483 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754329AbcDMWeQ (ORCPT ); Wed, 13 Apr 2016 18:34:16 -0400 Received: by mail-pf0-f169.google.com with SMTP id n1so39263633pfn.2 for ; Wed, 13 Apr 2016 15:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Pa1BDpcTIVK16jnQub5V+hvYrApbVbFMjmw03Lnw2OQ=; b=cliPFCgRjHaan8YumxMSqHlD7e5b153aR512NrrCI00u8f3hk6AhhFzqQRPTkPmOQ1 XEjxF1t35IJvbYz5x8sc2ko3CrkwuqHYiVbgkjzGakN/d3VhW8DFUij22HDAJ/1kXTsx wLyh4GG2ZO3GUdcTxVHY3Yt21VAvZWJtJUhOzjE4jS2fb0qAeNJvrts+nDwj8Zr2ZRnT k7NpMT/Om2TKPh/Tgz+Nl3mRfb4IvCPtQzMHcvziTN28n7kDAZA/pvNbbSfBHsV+sFV8 AXCYSFlaCgRLQKDDPFv3AxV7C9pHo8xx+jVMcJTOePiYWb38Mbh7o/GAr99jlgHG0pWS H3uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Pa1BDpcTIVK16jnQub5V+hvYrApbVbFMjmw03Lnw2OQ=; b=DkuZ2y8RpaP9PFmJF4mS+xwmsENK2xvSNPrKZWXl0ZEzlveRwJgu/0QxNsvqHIBkUg vzWNMlj+MjV2dzW0enqXJXvjmT2QvJRIiu8+lfZ2vu2sPhLtRxrHNG5nZd/giDQRIQZ9 68reaOlAkvJRfVabtvk1tK8BIN+8NYARJ+6WatwQDS2SN5XAOSQYNt4Sy5hdGkdpGFX3 2Hfnpt2913k+kgE1EmK8+u4rBYnxf7Ng3AiJw0jOkFuVl9NVnpsuI6BJWi26Oo4qIhVT EmnfQe7A8AlBnK3zFRC0XZ+Qo2PPDaQHwtNuVvJXsExtVhyGoEHOJlm/ZkrjIMsrF3dA 8y7w== X-Gm-Message-State: AOPr4FVEMIduUPCNgBz6/3hm+N6XKLrtYWrRKdkQY23+EF7LgiiU2GDxSLDxaTQ24yBgZDQG X-Received: by 10.98.82.134 with SMTP id g128mr5493744pfb.113.1460586855826; Wed, 13 Apr 2016 15:34:15 -0700 (PDT) Received: from gwendal.mtv.corp.google.com ([172.22.64.242]) by smtp.gmail.com with ESMTPSA id 27sm53332998pfo.58.2016.04.13.15.34.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Apr 2016 15:34:14 -0700 (PDT) From: Gwendal Grignou 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 Message-Id: <1460586824-40688-2-git-send-email-gwendal@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1460586824-40688-1-git-send-email-gwendal@chromium.org> References: <1460586824-40688-1-git-send-email-gwendal@chromium.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Gwendal Grignou --- 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