Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp993227ybh; Wed, 22 Jul 2020 19:48:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcBa5PyfTn5qUSFX0KKbMO1olMbE2PBlxWWskFWUcHpx+OQ6hvYFrj8qcI+m8e0z+cuJOi X-Received: by 2002:a17:906:e294:: with SMTP id gg20mr2240398ejb.521.1595472503569; Wed, 22 Jul 2020 19:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595472503; cv=none; d=google.com; s=arc-20160816; b=1Lp5IbdutIezNdZNIZYOULhh+N9glVFV6mzxEiP5RNQyIiVO9vuWuNwL4kAkd1G44c Dv2rQBUcfZQffDh0BcDnB2tLc8DKtKhAycpNPypSzH+Hn5v6KeA5Xzk7f6Qg7fu6vt97 9CLW07l27fRy9241y/CAhm8rvAnPyPRTaMa/qOeTzYHWMiRb42wEeGfcGhGnGW29y972 1urMiqrCX9tAEqBo6HTjCurVOToW1qbQaDYLNSWTwDLXP3fv6oJP3mLky4INoHn/Kh1p 8bcjcesS5ra1LSFaJ+OMbpmMnsp3sfQ/bolZZXtDPlzbQ3LVCFTaTsS+K4t35OX93H/B BSjA== 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=ZYYl7C2C3XkUBcES8NesjtqLRO46HerlpPpxaHi1mZc=; b=HiOdWP66oN+XnvjrEuLbupEPROpxLPhAXl5NSriWusLgWcix+tJysQZ3zryshnHvZG MoQi/MaFjfRmKK0M1Ut6IxAgns8UV01IyM7WcgCSLjDaeos15dYXVYjT7j6D5T/df/nH HXolAMQIAxmhyUd+A8kR4Z8G/2VTVw2teJrWMmRBuXkRv3ODj6Ok0fcNSXTwtlkFhGb7 Jq7l16TC/r6y8DmLy7xm+3tk5wLHsvc7AUDIHRxA+EUozYiB/2hKnStysdK9ryZC5tBd vDFnBkH6R9a0ybUBjQ9duolW/BEq6tzVU90VMHmvMy8f+LqLllgzmrf4iDqFFFjuWJMN WUqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=UU6PVu44; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dg8si1157762edb.184.2020.07.22.19.48.00; Wed, 22 Jul 2020 19:48:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=UU6PVu44; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733276AbgGWCpf (ORCPT + 99 others); Wed, 22 Jul 2020 22:45:35 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:16860 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728902AbgGWCpe (ORCPT ); Wed, 22 Jul 2020 22:45:34 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1595472334; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=ZYYl7C2C3XkUBcES8NesjtqLRO46HerlpPpxaHi1mZc=; b=UU6PVu44d/hHVjUp2/3avHG6Xv6k+xG2/NgKIvcdBMnrWpA6yOnweotPwsnntZ450zcDogfw sY3giiKD6isme4i6Qpf0UKBRp6vaCQUztKUXdv9brx3gspA6zDCzksLnYmdACWsV2ZIN7v+X 1aJf+9PC2NzgapuHWenHOqbRgYo= X-Mailgun-Sending-Ip: 69.72.43.7 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 smtp-out-n13.prod.us-east-1.postgun.com with SMTP id 5f18f9b27c8ca473a8b70f85 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 23 Jul 2020 02:45:06 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 12E1AC4339C; Thu, 23 Jul 2020 02:45:05 +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: hongwus) by smtp.codeaurora.org (Postfix) with ESMTPSA id 17EB7C433C6; Thu, 23 Jul 2020 02:45:04 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 23 Jul 2020 10:45:04 +0800 From: hongwus@codeaurora.org To: Can Guo Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org, rnayak@codeaurora.org, sh425.lee@samsung.com, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Bart Van Assche , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 1/9] scsi: ufs: Add checks before setting clk-gating states In-Reply-To: <1595471649-25675-2-git-send-email-cang@codeaurora.org> References: <1595471649-25675-1-git-send-email-cang@codeaurora.org> <1595471649-25675-2-git-send-email-cang@codeaurora.org> Message-ID: X-Sender: hongwus@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-07-23 10:34, Can Guo wrote: > Clock gating features can be turned on/off selectively which means its > state information is only important if it is enabled. This change makes > sure that we only look at state of clk-gating if it is enabled. > > Signed-off-by: Can Guo > Reviewed-by: Avri Altman > --- > drivers/scsi/ufs/ufshcd.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index cdff7e5..99bd3e4 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -1839,6 +1839,8 @@ static void ufshcd_init_clk_gating(struct ufs_hba > *hba) > if (!ufshcd_is_clkgating_allowed(hba)) > return; > > + hba->clk_gating.state = CLKS_ON; > + > hba->clk_gating.delay_ms = 150; > INIT_DELAYED_WORK(&hba->clk_gating.gate_work, ufshcd_gate_work); > INIT_WORK(&hba->clk_gating.ungate_work, ufshcd_ungate_work); > @@ -2541,7 +2543,8 @@ static int ufshcd_queuecommand(struct Scsi_Host > *host, struct scsi_cmnd *cmd) > err = SCSI_MLQUEUE_HOST_BUSY; > goto out; > } > - WARN_ON(hba->clk_gating.state != CLKS_ON); > + WARN_ON(ufshcd_is_clkgating_allowed(hba) && > + (hba->clk_gating.state != CLKS_ON)); > > lrbp = &hba->lrb[tag]; > > @@ -8315,8 +8318,11 @@ static int ufshcd_suspend(struct ufs_hba *hba, > enum ufs_pm_op pm_op) > /* If link is active, device ref_clk can't be switched off */ > __ufshcd_setup_clocks(hba, false, true); > > - hba->clk_gating.state = CLKS_OFF; > - trace_ufshcd_clk_gating(dev_name(hba->dev), hba->clk_gating.state); > + if (ufshcd_is_clkgating_allowed(hba)) { > + hba->clk_gating.state = CLKS_OFF; > + trace_ufshcd_clk_gating(dev_name(hba->dev), > + hba->clk_gating.state); > + } > > /* Put the host controller in low power mode if possible */ > ufshcd_hba_vreg_set_lpm(hba); > @@ -8456,6 +8462,11 @@ static int ufshcd_resume(struct ufs_hba *hba, > enum ufs_pm_op pm_op) > if (hba->clk_scaling.is_allowed) > ufshcd_suspend_clkscaling(hba); > ufshcd_setup_clocks(hba, false); > + if (ufshcd_is_clkgating_allowed(hba)) { > + hba->clk_gating.state = CLKS_OFF; > + trace_ufshcd_clk_gating(dev_name(hba->dev), > + hba->clk_gating.state); > + } > out: > hba->pm_op_in_progress = 0; > if (ret) Reviewed-by: Hongwu Su