From patchwork Thu Mar 27 15:32:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 3898321 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E989DBF540 for ; Thu, 27 Mar 2014 15:33:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF4B42013A for ; Thu, 27 Mar 2014 15:33:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B941420225 for ; Thu, 27 Mar 2014 15:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756507AbaC0Pdm (ORCPT ); Thu, 27 Mar 2014 11:33:42 -0400 Received: from moutng.kundenserver.de ([212.227.126.131]:55012 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754659AbaC0Pdk (ORCPT ); Thu, 27 Mar 2014 11:33:40 -0400 Received: from localhost.localdomain ([109.104.33.138]) by mrelayeu.kundenserver.de (node=mreue006) with ESMTP (Nemesis) id 0MYHJs-1WXa1B3Ofw-00UqA2; Thu, 27 Mar 2014 16:33:21 +0100 From: Stefan Wahren To: fabio.estevam@freescale.com Cc: chris@printf.net, otavio@ossystems.com.br, Peter.Chen@freescale.com, Kernel@pengutronix.de, linux-mmc@vger.kernel.org Subject: [PATCH] mmc: core: Use maximum timeout values in case TACC field is zero Date: Thu, 27 Mar 2014 16:32:48 +0100 Message-Id: <1395934368-29207-1-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 1.7.10.4 X-Provags-ID: V02:K0:7+h/e345ktQHKXkvju4q9oLnsfCz+wzQn54HyQyZyCa XXhnPvVbPxCXUPTrUtmDIMqfi2fB/A6MK+WbeQ3PSmQqsHld91 co9LP/72/QKWCrNrp7qSMxf655f0SrTBLUSD1TJHNEw4+DxOIP 2Mc8E7GAEeeZZFvLID8tI8/a67uNTopm1OR1rsyGPxEJYkVHSl PVGIvir42d0lONHixGb2JzkUNOZTLPEAaQ80DfcbFyVfJdoWX4 7tPnCLFEla5ucZIz8W18bnQLf4ez7OQkt6ur3+xrF0ho49/Txs /Q9MG41Y8PgWjIRu1dk/Ph8wniMUsLQudzowugJkTSsVIizc2D a8laqzJtzof78xFYD3XbSJJ/Mlwdyc9F3Z3up2kzaM+zySUl00 ALoXxMW/8+KbpztbmatgSGrRP5IjAcdQag= 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.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 When plugging a specific micro SD card at MMC socket of a custom i.MX28 board, we get the following kernel warning: WARNING: CPU: 0 PID: 30 at drivers/mmc/host/mxs-mmc.c:342 mxs_mmc_start_cmd+0x34c/0x378() Modules linked in: CPU: 0 PID: 30 Comm: kworker/u2:1 Not tainted 3.14.0-rc5 #8 Workqueue: kmmcd mmc_rescan [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (warn_slowpath_common+0x6c/0x8c) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24) [] (warn_slowpath_null) from [] (mxs_mmc_start_cmd+0x34c/0x378) [] (mxs_mmc_start_cmd) from [] (mmc_start_request+0xc4/0xf4) [] (mmc_start_request) from [] (mmc_wait_for_req+0x50/0x164) [] (mmc_wait_for_req) from [] (mmc_app_send_scr+0x158/0x1c8) [] (mmc_app_send_scr) from [] (mmc_sd_setup_card+0x80/0x3c8) [] (mmc_sd_setup_card) from [] (mmc_sd_init_card+0x124/0x66c) [] (mmc_sd_init_card) from [] (mmc_attach_sd+0xac/0x174) [] (mmc_attach_sd) from [] (mmc_rescan+0x25c/0x2d8) [] (mmc_rescan) from [] (process_one_work+0x1b4/0x4ec) [] (process_one_work) from [] (worker_thread+0x130/0x464) [] (worker_thread) from [] (kthread+0xb4/0xd0) [] (kthread) from [] (ret_from_fork+0x14/0x34) The error is due to an invalid value in CSD register of a specific 2GB micro SD card. The CSD version of this card is 1.0 but the TACC field has the invalid value 0. Since the kernel is making use of this TACC field to calculate the SD card timeout, an invalid value 0 leads to a warning at mxs_ns_to_ssp_ticks() and later the following misleading error messages appears in a loop: mxs-mmc 80010000.ssp: card claims to support voltages below defined range mxs-mmc 80010000.ssp: no support for card's volts mmc0: error -22 whilst initialising MMC card This error is only found on this 2GB SD card on mxs platform. On x86 this card works without any problems. The following patch based on the work of Peter Chen and Otavio Salvador. It catches the case that the determined timeout is still 0 and set it's to a valid value. Successful tested on a i.MX28 board. Signed-off-by: Stefan Wahren --- drivers/mmc/core/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 098374b..a9cd996 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -815,6 +815,10 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card) data->timeout_ns = limit_us * 1000; data->timeout_clks = 0; } + + /* assign limit value if invalid */ + if (data->timeout_ns == 0) + data->timeout_ns = limit_us * 1000; } /*