From patchwork Fri Apr 1 17:25:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwendal Grignou X-Patchwork-Id: 8726941 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 86BDC9F3D1 for ; Fri, 1 Apr 2016 17:25:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A5CE120390 for ; Fri, 1 Apr 2016 17:25:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9DE220303 for ; Fri, 1 Apr 2016 17:25:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751281AbcDARZ2 (ORCPT ); Fri, 1 Apr 2016 13:25:28 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:34587 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097AbcDARZ2 (ORCPT ); Fri, 1 Apr 2016 13:25:28 -0400 Received: by mail-pf0-f173.google.com with SMTP id x3so95721709pfb.1 for ; Fri, 01 Apr 2016 10:25:28 -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=doOV+pDReYE8U9srzaCM0Vc3TjQD4V5dGdmXK2o76Ew=; b=me6YEj4SK3emuC/Um0hdA94MSDhquMqmQB7swxdHMSaueUhtnnzE8n8AfjRWf1upf0 NMCK46xq2SmENQjd/i4I8sVPKNMbCiHXAqwmZeFflmyVQGMaHbWw4yI9PAHmVHl9oSKC IvhekDTJrNKf/3i9CZHWF9AdlgGSoazbQWcfEtAJVeapRbwHijKt7OQ8OD+fQlHscr0w bkEDi/BnCF+NbdZMTah1H042NfgvpGqaQJg3a7GWqJeg1UEePfzkvX5HMT0It+K/B2hY J99nkB9u3Evvc6npQOeOfmfs+USStRoEgttVdNsclzMYAidkQzEtka3E3iI++hbpaNHD okzQ== 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=doOV+pDReYE8U9srzaCM0Vc3TjQD4V5dGdmXK2o76Ew=; b=k1O7LlGFeH4BEYjeDZ6N8xdK+teOFdAHNf6knp8qoJSaxgVHgHb723DLngj4xwAIwd PfB7IZRvqgZXf54rTiUQI2kAvfokZuKm2v1hpUVF55M2uDPmdlB7ru3KYqagwP/IrOGh WRkjMAzAYKu8Zp3DJD6uCKsITHdoaGigx//qtOV5yJiibyjAMWBQQRZ8o5dixT3MROIO XxqeNn9Dic9LxmEozplpMpMIiPCt02Wn3k8wToF6xCcJDjs4Sf2Tf+TQmAdAJWHRZtdE aQWT7Z/e727bYtAc98qWADlRMY0r1FIgQzHL650kTCW6NW6x04Q5YnNiBA27gT8z3/rh IG6A== X-Gm-Message-State: AD7BkJKBPQ7VAIl/zAcIrCOZzW2zE+l27bO13g1MAbAY23Qg+ANrSkQkBh38ilrPA5borte6 X-Received: by 10.98.87.216 with SMTP id i85mr238652pfj.61.1459531527533; Fri, 01 Apr 2016 10:25:27 -0700 (PDT) Received: from gwendal.mtv.corp.google.com ([172.22.64.242]) by smtp.gmail.com with ESMTPSA id f12sm21298722pfd.87.2016.04.01.10.25.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Apr 2016 10:25:26 -0700 (PDT) From: Gwendal Grignou To: ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org Subject: [PATCH v2] mmc: core: in mmc_hw_reset(), allow power cycle. Date: Fri, 1 Apr 2016 10:25:22 -0700 Message-Id: <1459531522-31874-1-git-send-email-gwendal@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1459529180-32604-1-git-send-email-gwendal@chromium.org> References: <1459529180-32604-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 When the eMMC device does not support/allow sending RST_n signal, do a brute force power cycle instead of returning EOPNOTSUPP. Signed-off-by: Gwendal Grignou --- Changes in v2: - Fix indentation. - Use card instead of host->card when available. drivers/mmc/core/core.c | 5 +++-- drivers/mmc/core/mmc.c | 18 ++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index d8bbc78..d5bc2d8 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2468,8 +2468,9 @@ int mmc_hw_reset(struct mmc_host *host) ret = host->bus_ops->reset(host); mmc_bus_put(host); - if (ret != -EOPNOTSUPP) - pr_warn("%s: tried to reset card\n", mmc_hostname(host)); + if (ret) + pr_warn("%s: tried to reset card, got error %d\n", + mmc_hostname(host), ret); return ret; } diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 96cc7e2..deb8c16 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1988,19 +1988,17 @@ static int mmc_reset(struct mmc_host *host) { struct mmc_card *card = host->card; - if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset) - return -EOPNOTSUPP; - - if (!mmc_can_reset(card)) - return -EOPNOTSUPP; - mmc_set_clock(host, host->f_init); - - host->ops->hw_reset(host); - + if ((host->caps & MMC_CAP_HW_RESET) && host->ops->hw_reset && + mmc_can_reset(card)) { + /* If the card accept RST_n signal, send it. */ + host->ops->hw_reset(host); + } else { + /* Do a brute force power cycle */ + mmc_power_cycle(host, card->ocr); + } /* Set initial state and call mmc_set_ios */ mmc_set_initial_state(host); - return mmc_init_card(host, card->ocr, card); }