From patchwork Wed Dec 9 16:23:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Bosch X-Patchwork-Id: 1413504 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=posteo.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=posteo.net header.i=@posteo.net header.a=rsa-sha256 header.s=2017 header.b=ODOVAW+f; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Crj7d6TQMz9sPB for ; Thu, 10 Dec 2020 03:25:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CEB8082580; Wed, 9 Dec 2020 17:24:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=posteo.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=posteo.net header.i=@posteo.net header.b="ODOVAW+f"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F3A8282591; Wed, 9 Dec 2020 17:24:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8F3C6821A4 for ; Wed, 9 Dec 2020 17:24:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=posteo.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=stefan_b@posteo.net Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 0AC6B160066 for ; Wed, 9 Dec 2020 17:24:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1607531088; bh=KV0QYu7UIE1yKKccPXfEWCaP9a4vz5aPzdlS+pxvuVE=; h=From:To:Cc:Subject:Date:From; b=ODOVAW+fEsM66MHPktDQuaxaGVD6TCvV5DWGmpyE4WjLoZ7NBF17QE3KvWKGwX7B4 c4b6lOlls3Z1IcsiHfkQLRgYnWAYuLvs3MfAvBcJu7Pb0UnaAknVpRzDYr84gb524i EBxFn+aMxU+5WVLrzbYKmjsQjYSPsV0/nMtUwxHove7YTzvUQ8Nq8Jr3rNPxRXe5UL mljhdbMKNy7peV2SSYAFwf+Mbih0zLHdKFi+HBtbS9ueDoYLQWC7DTXTxqoP9lqRNo Dmae3EvjMgML3zSrZSv7/DXWW9TE9bsVzqLKeMcfRTEtV+lOhqfkfwMibDjxmmqVwx sKbujQMz4ciDw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Crj7L5cV8z9rxb; Wed, 9 Dec 2020 17:24:46 +0100 (CET) From: Stefan Bosch To: u-boot@lists.denx.de, Peng Fan Cc: Stefan Bosch , Ashok Reddy Soma , Faiz Abbas , Heinrich Schuchardt , Jaehoon Chung , Marek Vasut , Masahiro Yamada , Simon Glass , Yangbo Lu Subject: [RFC PATCH v1 1/1] mmc: fix response timeout after switch command Date: Wed, 9 Dec 2020 17:23:18 +0100 Message-Id: <20201209162319.17433-2-stefan_b@posteo.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201209162319.17433-1-stefan_b@posteo.net> References: <20201209162319.17433-1-stefan_b@posteo.net> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean After issuing the switch command: Wait until 'current state' of the card status becomes 'tran'. This prevents from response timeout at the next command because of 'current state' = 'data'. Signed-off-by: Stefan Bosch --- drivers/mmc/mmc.c | 3 ++- include/mmc.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index a47700e313..8ccd2058a9 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -823,7 +823,8 @@ static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value, value); return -EIO; } - if (!ret && (status & MMC_STATUS_RDY_FOR_DATA)) + if (!ret && (status & MMC_STATUS_RDY_FOR_DATA) && + (status & MMC_STATUS_CURR_STATE) == MMC_STATE_TRANS) return 0; udelay(100); } while (get_timer(start) < timeout_ms); diff --git a/include/mmc.h b/include/mmc.h index 1d377e0281..18402494c6 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -178,6 +178,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define MMC_STATUS_ERROR (1 << 19) #define MMC_STATE_PRG (7 << 9) +#define MMC_STATE_TRANS (4 << 9) #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */ #define MMC_VDD_20_21 0x00000100 /* VDD voltage 2.0 ~ 2.1 */