Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp356501ybf; Thu, 27 Feb 2020 22:55:48 -0800 (PST) X-Google-Smtp-Source: APXvYqyi0Udc8YtBJh0dgvuI8nPDVnXblf+AJJqQb7DQP589wYme9iUQOKZts8rYD+vsuqkK5HiQ X-Received: by 2002:a05:6830:1e86:: with SMTP id n6mr2158800otr.321.1582872947986; Thu, 27 Feb 2020 22:55:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582872947; cv=none; d=google.com; s=arc-20160816; b=YjV5pxusE6MJ/6MkemWGHwmZEAQB6qUyHZRWblz/dcc/tuAAhfOPQZK+A2o4Z24hfP 58XzrI5kP8Ul5dChD+ONEqlWJ8y8QKmklDhpKt7T/4e0qj65eP1Kd2xW2hS0JhQ9Kg5V NeS+bOmdJUlywIQbH3LxmQ3c6ExndOptkzCkWcG7Fxnt2Tq99UAbU3SWrJ+Ra5zbvG1z duOk9yq5k3zkysf1i3nj1r93ealxscwFTGlCl0eTtCwtw0Uef5T2h0fYMcVnrXOMk2QM y87VjKrzMal/T8BjK/mSUNXMNGUWpzW/b0jwh2DpKVn2tEgtbMQDdDzqk5eYtTG7c6kx dACQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature; bh=ocx4fj9vAB5RcFI/K8qcqaNpKxontpgTVQkM0E6lBf0=; b=pc6DluX3/gXjvDZop103a3ZRV6dlleBOPK8xMHrUufvz91wKGx1Yho+SzPCf/qrnEo 5zDmH+hbuAdjFkUymH+LodeVbIT2j5XvsQWsIyL9ktJnchOjYPEBDlgrh/x67vrWKi5D aFnauth8v8N9BqqXLTRKTiG6xAmnrMoSGw88dX6RsMvYn6EoxI/kNyKWEHt/mVTquCbd IQjJCjGwHC8ZdQGbigHE3mJZ9OfDS3VABMmyimrBSZIKPOz5mNYK/prAd0iN3Q+hFUTT UpNqClNM0nMoURzXzQP0P9fsY9wokVMoeJ5e9X4uOqna0YETA1Hzp6GTd2k5pC2zRi3D PH/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=jxcmDlc0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si1067449otk.234.2020.02.27.22.55.36; Thu, 27 Feb 2020 22:55:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=jxcmDlc0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726816AbgB1GzM (ORCPT + 99 others); Fri, 28 Feb 2020 01:55:12 -0500 Received: from mail27.static.mailgun.info ([104.130.122.27]:64796 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbgB1GzM (ORCPT ); Fri, 28 Feb 2020 01:55:12 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582872911; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=ocx4fj9vAB5RcFI/K8qcqaNpKxontpgTVQkM0E6lBf0=; b=jxcmDlc0EPKhZb4PLxvPAgb3CU8GqXcpBts6KP/SGurlXh05vlvPkA+maMyo8YP/edx98zMT gHIooXzGSrPEiJ4klKkhfVa2Hm8cTUqSoTDG9T6n8teCpF/OfJm+XXdJec6SxQl6WSk+1NUO PDuPhz/X/BXt5rfnyw8QDyfC48E= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e58b93f.7ff823006228-smtp-out-n03; Fri, 28 Feb 2020 06:54:55 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id E44C8C447A3; Fri, 28 Feb 2020 06:54:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [10.206.25.58] (blr-c-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sayalil) by smtp.codeaurora.org (Postfix) with ESMTPSA id 217EBC43383; Fri, 28 Feb 2020 06:54:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 217EBC43383 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=sayalil@codeaurora.org Subject: Re: [PATCH RFC] mmc: sdhci-msm: Toggle fifo write clk after ungating sdcc clk To: Veerabhadrarao Badiganti , bjorn.andersson@linaro.org, adrian.hunter@intel.com, robh+dt@kernel.org, ulf.hansson@linaro.org, asutoshd@codeaurora.org, stummala@codeaurora.org, ppvk@codeaurora.org, rampraka@codeaurora.org, sboyd@kernel.org, georgi.djakov@linaro.org, mka@chromium.org Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, agross@kernel.org, linux-mmc-owner@vger.kernel.org References: <1582190446-4778-1-git-send-email-sayalil@codeaurora.org> <1582190446-4778-2-git-send-email-sayalil@codeaurora.org> <4e4f1e44-8033-94e9-641c-a74232727895@codeaurora.org> From: Sayali Lokhande Message-ID: Date: Fri, 28 Feb 2020 12:24:45 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <4e4f1e44-8033-94e9-641c-a74232727895@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Veera, On 2/24/2020 7:19 PM, Veerabhadrarao Badiganti wrote: > > On 2/20/2020 2:50 PM, Sayali Lokhande wrote: >> From: Ram Prakash Gupta >> >> During GCC level clock gating of MCLK, the async FIFO >> gets into some hang condition, such that for the next >> transfer after MCLK ungating, first bit of CMD response >> doesn't get written in to the FIFO. This cause the CPSM >> to hang eventually leading to SW timeout. >> >> To fix the issue, toggle the FIFO write clock after >> MCLK ungated to get the FIFO pointers and flags to >> valid states. >> >> Change-Id: Ibef2d1d283ac0b6983c609a4abc98bc574d31fa6 >> Signed-off-by: Ram Prakash Gupta >> Signed-off-by: Sayali Lokhande >> --- >>   drivers/mmc/host/sdhci-msm.c | 43 >> +++++++++++++++++++++++++++++++++++++++++++ >>   1 file changed, 43 insertions(+) >> >> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c >> index c3a160c..eaa3e95 100644 >> --- a/drivers/mmc/host/sdhci-msm.c >> +++ b/drivers/mmc/host/sdhci-msm.c >> @@ -127,6 +127,8 @@ >>   #define CQHCI_VENDOR_CFG1    0xA00 >>   #define CQHCI_VENDOR_DIS_RST_ON_CQ_EN    (0x3 << 13) >>   +#define RCLK_TOGGLE 0x2 >> + >>   struct sdhci_msm_offset { >>       u32 core_hc_mode; >>       u32 core_mci_data_cnt; >> @@ -1554,6 +1556,43 @@ static void __sdhci_msm_set_clock(struct >> sdhci_host *host, unsigned int clock) >>       sdhci_enable_clk(host, clk); >>   } >>   +/* >> + * After MCLK ugating, toggle the FIFO write clock to get >> + * the FIFO pointers and flags to valid state. >> + */ >> +static void sdhci_msm_toggle_fifo_write_clk(struct sdhci_host *host) >> +{ >> +    struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); >> +    struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); >> +    const struct sdhci_msm_offset *msm_offset = >> +                    msm_host->offset; >> +    struct mmc_card *card = host->mmc->card; >> + >> +    if (msm_host->tuning_done || >> +            (card && card->ext_csd.strobe_support && >> +            card->host->ios.enhanced_strobe)) { > > This issue is present on only HS400ES mode. > > If(host->ios.enhanced_strob) check should be sufficient, other checks > are not needed. Agree, Will update. > >> +        /* >> +         * set HC_REG_DLL_CONFIG_3[1] to select MCLK as >> +         * DLL input clock >> +         */ >> +        writel_relaxed(((readl_relaxed(host->ioaddr + >> +            msm_offset->core_dll_config_3)) >> +            | RCLK_TOGGLE), host->ioaddr + >> +            msm_offset->core_dll_config_3); >> +        /* ensure above write as toggling same bit quickly */ >> +        wmb(); >> +        udelay(2); >> +        /* >> +         * clear HC_REG_DLL_CONFIG_3[1] to select RCLK as >> +         * DLL input clock >> +         */ >> +        writel_relaxed(((readl_relaxed(host->ioaddr + >> +            msm_offset->core_dll_config_3)) >> +            & ~RCLK_TOGGLE), host->ioaddr + >> +            msm_offset->core_dll_config_3); >> +    } >> +} >> + >>   /* sdhci_msm_set_clock - Called with (host->lock) spinlock held. */ >>   static void sdhci_msm_set_clock(struct sdhci_host *host, unsigned >> int clock) >>   { >> @@ -2149,6 +2188,10 @@ static __maybe_unused int >> sdhci_msm_runtime_resume(struct device *dev) >>                          msm_host->bulk_clks); >>       if (ret) >>           return ret; >> +    if (host->mmc && >> +            (host->mmc->ios.timing == MMC_TIMING_MMC_HS400)) > These checks are not needed. You can have these checks within > sdhci_msm_toggle_fifo_write_clk Agree. Will update. >> + sdhci_msm_toggle_fifo_write_clk(host); >> + >>       /* >>        * Whenever core-clock is gated dynamically, it's needed to >>        * restore the SDR DLL settings when the clock is ungated.