Received: by 10.192.165.148 with SMTP id m20csp5171008imm; Tue, 24 Apr 2018 15:10:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx48EpgYNL39MOz1WxDUmrsNEySPppPsO4cz+jV7xO3noOpLn25cHOTlBug48TKappjGh94y2 X-Received: by 10.98.7.83 with SMTP id b80mr25481577pfd.133.1524607827057; Tue, 24 Apr 2018 15:10:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524607827; cv=none; d=google.com; s=arc-20160816; b=rGDQHWfCJWdwx6FUh022RWak7p1xWo7jupzdN5S2m/tfGt7iVXH/n6TLZD2qV+Ajkw kOWRM817fVmBcyuJgqXGai746RhFjArSr7vkYraFzYXTt/GwuePzhe/XFIktAzYLkPLH Vj2S+sPd1HiVGuAprO6r9Q7EYT+zsc/HEgqxc47zPOqBpdFZfKBv83VHxvoYJNxS1vTK eSFOCWLL7TcuwpwutMeP3QNS7OVnI5YGbtcARj2uQXx/0qZZZAdf3vho2RZTWD9d8pvc xEbR2M/R2PTQlOUvE8u+8e0xoiRmZcQpgghuUPPCCJOViJ9Xh1Dmh8CWsxyMOSKIAxEN AR/w== 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:dkim-signature :arc-authentication-results; bh=cE0ZM/e6mFOhOwTTTBDXKM/PuOzwSm2RNcsTpJVEQXI=; b=pvn+QV712UKqqLoOqxTW1JNtxGdKuaGnwnmC/r76nGNstYj9jbcZzzJq5dTDMy0LhE w30tYf4n2Cscf+U8MsbdPol89LkA2P9AXSXAz5irgMgnh9pSf4wzkVJxvbPXfmL4AUnh 0pP/xVRiMQW+64ctwqNu1GgophJdyrVXdl9w5yt1kqlucZiUFdQVQ5NdVFJepNJcI3q7 +bUTj5uu3B/t6GWrVYtb7fuY431MQRtVj+HYey43ylsodWUhC9i/e9WF3b8KJvhjJ1sS 46hgdOxo7wuiJD8ATC8t2TBXQj14tv+3WAXYsNSmm7uaN3dLnp0EvUHLYRl9FIdtaF97 zqEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=kt7IfpJo; dkim=pass header.i=@codeaurora.org header.s=default header.b=LlLr14rT; 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 h186si12596330pge.324.2018.04.24.15.10.11; Tue, 24 Apr 2018 15:10:27 -0700 (PDT) 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=pass header.i=@codeaurora.org header.s=default header.b=kt7IfpJo; dkim=pass header.i=@codeaurora.org header.s=default header.b=LlLr14rT; 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 S1751285AbeDXWI4 (ORCPT + 99 others); Tue, 24 Apr 2018 18:08:56 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:43322 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750766AbeDXWIy (ORCPT ); Tue, 24 Apr 2018 18:08:54 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C3B3A60A06; Tue, 24 Apr 2018 22:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524607733; bh=4lWdo+w8qFX85M85H6WfJBoPB5zfNqCAxceS6MtHMdI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kt7IfpJoZ7TIxuI/4P1tZPwjsbZyFGJiIn0sOMuum10zWRdZWGxFx0/dhw16xf5a1 p1aU8C7AwLiXxCJwVyJLkngIeYXu5saxH0GPhSfsrZjTj9KqkR3FzsmpRYp3+gdQnH VpW+TxrjjAVrEWXB6rFxe5YScyOWTL3Le7KPHT+Q= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 90B6260310; Tue, 24 Apr 2018 22:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524607732; bh=4lWdo+w8qFX85M85H6WfJBoPB5zfNqCAxceS6MtHMdI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LlLr14rTUGTzbtWGzbZ7RUToIMTK2g1obrCtYQHw2Ykn5CyYYRVY95BsupXQOouma hOxTZmTN3ohODPUuzqlmDvyVxiLAzRdpz+RJP4WM9ibGLVqDHVaBCm6pBSmGEVnYVH pRK/0VijlfuUb5RBLW/eV84VZjLeeBhm4x66hp6s= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 24 Apr 2018 15:08:52 -0700 From: Subhash Jadavani To: Bjorn Andersson Cc: Vinayak Holikatti , "James E.J. Bottomley" , "Martin K. Petersen" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , linux-scsi@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vivek Gautam , linux-scsi-owner@vger.kernel.org Subject: Re: [PATCH 3/3] scsi: ufs: Use freq table with devfreq In-Reply-To: <20180424002016.9205-4-bjorn.andersson@linaro.org> References: <20180424002016.9205-1-bjorn.andersson@linaro.org> <20180424002016.9205-4-bjorn.andersson@linaro.org> Message-ID: <5e59150bf025e2caa1deadfec7293ecd@codeaurora.org> X-Sender: subhashj@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-04-23 17:20, Bjorn Andersson wrote: > devfreq requires that the client operates on actual frequencies, not > only 0 and UMAX_INT and as such UFS brok with the introduction of > f1d981eaecf8 ("PM / devfreq: Use the available min/max frequency"). > > This patch registers the frequencies of the first clock with devfreq > and > use these to determine if we're trying to step up or down. > > Signed-off-by: Bjorn Andersson > --- > drivers/scsi/ufs/ufshcd.c | 39 ++++++++++++++++++++++++++++++++------- > 1 file changed, 32 insertions(+), 7 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 2253f24309ec..07b1f3c7bd2d 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -1168,16 +1168,13 @@ static int ufshcd_devfreq_target(struct device > *dev, > struct ufs_hba *hba = dev_get_drvdata(dev); > ktime_t start; > bool scale_up, sched_clk_scaling_suspend_work = false; > + struct list_head *clk_list = &hba->clk_list_head; > + struct ufs_clk_info *clki; > unsigned long irq_flags; > > if (!ufshcd_is_clkscaling_supported(hba)) > return -EINVAL; > > - if ((*freq > 0) && (*freq < UINT_MAX)) { > - dev_err(hba->dev, "%s: invalid freq = %lu\n", __func__, *freq); > - return -EINVAL; > - } > - > spin_lock_irqsave(hba->host->host_lock, irq_flags); > if (ufshcd_eh_in_progress(hba)) { > spin_unlock_irqrestore(hba->host->host_lock, irq_flags); > @@ -1187,7 +1184,13 @@ static int ufshcd_devfreq_target(struct device > *dev, > if (!hba->clk_scaling.active_reqs) > sched_clk_scaling_suspend_work = true; > > - scale_up = (*freq == UINT_MAX) ? true : false; > + if (list_empty(clk_list)) { > + spin_unlock_irqrestore(hba->host->host_lock, irq_flags); > + goto out; > + } > + > + clki = list_first_entry(&hba->clk_list_head, struct ufs_clk_info, > list); > + scale_up = (*freq == clki->max_freq) ? true : false; > if (!ufshcd_is_devfreq_scaling_required(hba, scale_up)) { > spin_unlock_irqrestore(hba->host->host_lock, irq_flags); > ret = 0; > @@ -1257,11 +1260,33 @@ static struct devfreq_dev_profile > ufs_devfreq_profile = { > > static int ufshcd_devfreq_init(struct ufs_hba *hba) > { > + struct devfreq_dev_profile *profile; > + struct list_head *clk_list = &hba->clk_list_head; > + struct ufs_clk_info *clki; > struct devfreq *devfreq; > int ret; > > + /* Skip devfreq if we don't have any clocks in the list */ > + if (list_empty(clk_list)) > + return 0; > + > + profile = devm_kmemdup(hba->dev, &ufs_devfreq_profile, > + sizeof(ufs_devfreq_profile), GFP_KERNEL); > + if (!profile) > + return -ENOMEM; > + > + profile->max_state = 2; > + profile->freq_table = devm_kcalloc(hba->dev, profile->max_state, > + sizeof(unsigned long), GFP_KERNEL); > + if (!profile->freq_table) > + return -ENOMEM; > + > + clki = list_first_entry(&hba->clk_list_head, struct ufs_clk_info, > list); > + profile->freq_table[0] = clki->min_freq; > + profile->freq_table[1] = clki->max_freq; > + > devfreq = devm_devfreq_add_device(hba->dev, > - &ufs_devfreq_profile, > + profile, > "simple_ondemand", > NULL); > if (IS_ERR(devfreq)) { Looks good to me. Reviewed-by: Subhash Jadavani -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project