Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4739004ybv; Mon, 17 Feb 2020 05:04:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyV1aNQZxEKbXEcBt05J4iLCQ5dJ5/L/MGhPzxpXfD8L8aW6het58ef9IwoF7+o6Ou022fG X-Received: by 2002:a9d:6a06:: with SMTP id g6mr11107398otn.305.1581944685811; Mon, 17 Feb 2020 05:04:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581944685; cv=none; d=google.com; s=arc-20160816; b=Fq5B5nneCMq0imUhkgIFe7J6rIVJbP1/4UfrhY72FspjcvHAXriuFUUUO3m14hJRqP gAL6BMVDMIwdBrlY3jbx+x94sVMWr2dacLgHCbP2B4ye5a96tTH7rG2bK3UKyuE3hztD 862ULWyuSU4rpWZqCOKitku/XvaVdYcZpIQuTGcP4vp1WG8jp+Qyn9+uXJ0l88ctEirw Mdk5X9HpT4LqbEEW9ShMi+ZibuYPP/LzdDC3q1fQrj6FL7BwZwE5jkHC+eRP/9xSR55A twyWgcjGh9Fr5tgYPIiSBscSSkBC6cWnxSmV+eRe9ymmB+AExuzPr4oBZkSxuYTVFG3+ dGbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=F6hhLqoUemqMuF73oXb4UEU9cz/dkxAFWWHo7Eh0TSQ=; b=iCAOob+fSaK09ErRp3bgGkgniqVgkfp9WdXqKMjAnMiOmsk/05f/Us7my0YqzZL0OT D4Z8A0aSwua19nbioufvI0QapdrwprPqhbhIQYAsV6TOyo5nS83eOoUNKzoDHIo6hGiX zBvKPubGnfDjOFYdTLwnjoRJbIOiAsjjA6ANOGI4eyIK3a3bNdnDDh3e/qnlOuCBSVTS pxKR5LqUkKmtMSiNBX4GiLmTFAl9vvAmzG/ZNJLsW7gfhFrIjSG76x1I4sXMrkXcxrDm L9rOFIWpprGQsnxwWRVk/QoeL1mxHvhS+2CkZQeRkDVgnpczmvp1+DHjqeHnOb+Of1bh GSzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=fhviTp3O; 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 t22si156057oth.211.2020.02.17.05.04.32; Mon, 17 Feb 2020 05:04:45 -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=fhviTp3O; 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 S1728442AbgBQM6X (ORCPT + 99 others); Mon, 17 Feb 2020 07:58:23 -0500 Received: from mail27.static.mailgun.info ([104.130.122.27]:43722 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727803AbgBQM6X (ORCPT ); Mon, 17 Feb 2020 07:58:23 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1581944302; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=F6hhLqoUemqMuF73oXb4UEU9cz/dkxAFWWHo7Eh0TSQ=; b=fhviTp3OMMKGR2AzKrTdH5LrYCbzzTByM+/LK+kEinEzN2W32rG3dQUdvGaN73FOwfqPqQLi jrKnbRcaYst99vH78ASM0XdYKjKGvl9vYfOX87qLChPIQoXeEybND0xjx1B9EykSi1UzzJ9k ynyPrnPnKcPviXxoCGaWQAdEKrg= 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 5e4a8ded.7f4a1e1257d8-smtp-out-n01; Mon, 17 Feb 2020 12:58:21 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id C827CC447A2; Mon, 17 Feb 2020 12:58:21 +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 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id E5411C4479D; Mon, 17 Feb 2020 12:58:20 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 17 Feb 2020 20:58:20 +0800 From: Can Guo To: Stanley Chu Cc: linux-scsi@vger.kernel.org, martin.petersen@oracle.com, avri.altman@wdc.com, alim.akhtar@samsung.com, jejb@linux.ibm.com, beanhuo@micron.com, asutoshd@codeaurora.org, matthias.bgg@gmail.com, bvanassche@acm.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kuohong.wang@mediatek.com, peter.wang@mediatek.com, chun-hung.wu@mediatek.com, andy.teng@mediatek.com Subject: Re: [PATCH v1 1/2] scsi: ufs: add required delay after gating reference clock In-Reply-To: <20200217093559.16830-2-stanley.chu@mediatek.com> References: <20200217093559.16830-1-stanley.chu@mediatek.com> <20200217093559.16830-2-stanley.chu@mediatek.com> Message-ID: X-Sender: cang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-02-17 17:35, Stanley Chu wrote: > In UFS version 3.0, a newly added attribute bRefClkGatingWaitTime > defines > the minimum time for which the reference clock is required by device > during > transition to LS-MODE or HIBERN8 state. > > Currently this time is detected and stored in > hba->dev_info.clk_gating_wait_us but applied to vendor implementatios > only. > Make it applied to reference clock named as "ref_clk" in device tree in > common path. > > Signed-off-by: Stanley Chu > --- > drivers/scsi/ufs/ufshcd.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 744b8254220c..7f60721f54d1 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -7417,8 +7417,10 @@ static int __ufshcd_setup_clocks(struct ufs_hba > *hba, bool on, > struct ufs_clk_info *clki; > struct list_head *head = &hba->clk_list_head; > unsigned long flags; > + unsigned long wait_us; > ktime_t start = ktime_get(); > bool clk_state_changed = false; > + bool ref_clk; > > if (list_empty(head)) > goto out; > @@ -7436,7 +7438,8 @@ static int __ufshcd_setup_clocks(struct ufs_hba > *hba, bool on, > > list_for_each_entry(clki, head, list) { > if (!IS_ERR_OR_NULL(clki->clk)) { > - if (skip_ref_clk && !strcmp(clki->name, "ref_clk")) > + ref_clk = !strcmp(clki->name, "ref_clk") ? true : false; > + if (skip_ref_clk && ref_clk) > continue; > > clk_state_changed = on ^ clki->enabled; > @@ -7449,6 +7452,9 @@ static int __ufshcd_setup_clocks(struct ufs_hba > *hba, bool on, > } > } else if (!on && clki->enabled) { > clk_disable_unprepare(clki->clk); > + wait_us = hba->dev_info.clk_gating_wait_us; > + if (ref_clk && wait_us) > + usleep_range(wait_us, wait_us + 10); Hi Stanley, If wait_us is 1us, it would be inappropriate to use usleep_range() here. You have checks of the delay in patch #2, but why it is not needed here? Thanks, Can Guo. > } > clki->enabled = on; > dev_dbg(hba->dev, "%s: clk: %s %sabled\n", __func__,