Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp786448ybb; Wed, 25 Mar 2020 09:33:30 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuui69/M3o7+GN5nz4z0DgkSA9HVIzj94W9PWKJ5sUHD8EKeJ1Kt1rDrxYBY+Fuyviwq4OS X-Received: by 2002:a9d:12a6:: with SMTP id g35mr3030354otg.333.1585154010168; Wed, 25 Mar 2020 09:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585154010; cv=none; d=google.com; s=arc-20160816; b=qCbf7zCyB/MN9KkqmM48thRk7bsY/Ncpcg4XgAYfNm0W0swq94iyQ4s2Ga2jyPRttN qHihtRU3eMr/ZzZfL1Qv8cpTcTkJTepSjvuSdSdIR+YGlwJRxg9m8pPgJG4BZ84IL3qJ g2CmIMSggzv3HMYvdUh7nwqNnHgFdLjk4lJbNIRhbN45uz0AP2tJ4hGKC7LW6Iw0Vytw mY/55T9q1zXpo0kTJbbbdXLgFOY79UN6fp8oSQjAfHz+8phE8aciZJ85eNnXRfZcRu4/ f4NPvxgsd5KtBZt2bf5eqPiRJ3DukynyqGlj75Rc4FIcCa/03ZG1O9+8QGQKv/7O5PEQ X7fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature; bh=5UvPwup7f3AuNdIm3PXIwT0XlBlphSX6/sF/XlEruEI=; b=meueyy5cAsROh9z3vhgJEh9POM3FdQhwk29tezVMY16iymA4B5tUgILWl4lua+wd52 pKWgYSfqH2keANTcrOMdgiVqXojSkyfgCfJtX9BYn9XRXw1Ksh0gK76iKlKGb3wD6WQG HaRmEX/2zO+JyVbQTcGREaiupgd/gGxzFYE+BuO31LZUa3zbbe7FhXH4s0CAjaNvVfBe NxZErc7eIT3Ai/i0wwaugFNlxez7eTBu+EGshVVaTODVm5ipSDvTt74YfkkNi0/zFljK 79UPBGEy8PmV6yxiSyiODw7k2f8psb7OpCxvVg3dbVrSoR+vGTDZUapwz8ZpOdlikHCe 2ggQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=vqLgD6gm; 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 a23si1713596oos.67.2020.03.25.09.33.17; Wed, 25 Mar 2020 09:33:30 -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=fail header.i=@mg.codeaurora.org header.s=smtp header.b=vqLgD6gm; 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 S1728137AbgCYQcb (ORCPT + 99 others); Wed, 25 Mar 2020 12:32:31 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:10589 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727994AbgCYQca (ORCPT ); Wed, 25 Mar 2020 12:32:30 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1585153949; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=5UvPwup7f3AuNdIm3PXIwT0XlBlphSX6/sF/XlEruEI=; b=vqLgD6gmPgXy4MvrPU89fuMTBZaY7MuOYZ7oom18PIPsWMvMM+Z9Ul7pQdoFOM3WWM2Tuf5k 1gYf0Npj/GWQjSBD+1EkCN02m0/Qg0s1oE0SAEAp3DCYRsbT80jH6W6nUPcGErd0imtiRkTG 37CulomPbR5zgEnO9+0k7zPsLgk= X-Mailgun-Sending-Ip: 104.130.122.26 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 5e7b879a.7f87b3858228-smtp-out-n03; Wed, 25 Mar 2020 16:32:26 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 786CBC43637; Wed, 25 Mar 2020 16:32:26 +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 [192.168.8.111] (cpe-70-95-153-89.san.res.rr.com [70.95.153.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: asutoshd) by smtp.codeaurora.org (Postfix) with ESMTPSA id B6F2CC433BA; Wed, 25 Mar 2020 16:32:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B6F2CC433BA 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=asutoshd@codeaurora.org Subject: Re: [PATCH v1 1/3] scsi: ufshcd: Update the set frequency to devfreq To: Avri Altman , "cang@codeaurora.org" , "martin.petersen@oracle.com" , "linux-scsi@vger.kernel.org" Cc: "linux-arm-msm@vger.kernel.org" , Alim Akhtar , "James E.J. Bottomley" , Stanley Chu , Bean Huo , Bart Van Assche , Venkat Gopalakrishnan , Tomas Winkler , open list References: From: "Asutosh Das (asd)" Message-ID: <3ea137ea-aade-31d8-a374-70c6f0d2dacc@codeaurora.org> Date: Wed, 25 Mar 2020 09:32:24 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/25/2020 6:11 AM, Avri Altman wrote: >> >> Currently, the frequency that devfreq provides the >> driver to set always leads the clocks to be scaled up. >> Hence, round the clock-rate to the nearest frequency >> before deciding to scale. >> >> Also update the devfreq statistics of current frequency. >> >> Signed-off-by: Asutosh Das >> --- >> drivers/scsi/ufs/ufshcd.c | 14 +++++++++++++- >> 1 file changed, 13 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c >> index 2a2a63b..4607bc6 100644 >> --- a/drivers/scsi/ufs/ufshcd.c >> +++ b/drivers/scsi/ufs/ufshcd.c >> @@ -1187,6 +1187,9 @@ static int ufshcd_devfreq_target(struct device >> *dev, >> if (!ufshcd_is_clkscaling_supported(hba)) >> return -EINVAL; >> >> + clki = list_first_entry(&hba->clk_list_head, struct ufs_clk_info, list); >> + /* Override with the closest supported frequency */ >> + *freq = (unsigned long) clk_round_rate(clki->clk, *freq); >> spin_lock_irqsave(hba->host->host_lock, irq_flags); > Please remind me what the spin lock is protecting here? Hmmm ... Nothing comes to my mind. I blamed it but it's a part of a bigger change. > >> if (ufshcd_eh_in_progress(hba)) { >> spin_unlock_irqrestore(hba->host->host_lock, irq_flags); >> @@ -1201,8 +1204,13 @@ static int ufshcd_devfreq_target(struct device >> *dev, >> goto out; >> } >> >> - clki = list_first_entry(&hba->clk_list_head, struct ufs_clk_info, list); >> + /* Decide based on the rounded-off frequency and update */ >> scale_up = (*freq == clki->max_freq) ? true : false; >> + if (scale_up) >> + *freq = clki->max_freq; > This was already established 2 lines above ? Good point - I'll change it. > >> + else >> + *freq = clki->min_freq; >> + /* Update the frequency */ >> if (!ufshcd_is_devfreq_scaling_required(hba, scale_up)) { >> spin_unlock_irqrestore(hba->host->host_lock, irq_flags); >> ret = 0; >> @@ -1250,6 +1258,8 @@ static int ufshcd_devfreq_get_dev_status(struct >> device *dev, >> struct ufs_hba *hba = dev_get_drvdata(dev); >> struct ufs_clk_scaling *scaling = &hba->clk_scaling; >> unsigned long flags; >> + struct list_head *clk_list = &hba->clk_list_head; >> + struct ufs_clk_info *clki; >> >> if (!ufshcd_is_clkscaling_supported(hba)) >> return -EINVAL; >> @@ -1260,6 +1270,8 @@ static int ufshcd_devfreq_get_dev_status(struct >> device *dev, >> if (!scaling->window_start_t) >> goto start_window; >> >> + clki = list_first_entry(clk_list, struct ufs_clk_info, list); >> + stat->current_frequency = clki->curr_freq; > Is this a bug fix? > devfreq_simple_ondemand_func is trying to establish the busy period, > but also uses the frequency in its calculation - which I wasn't able to understand how. > Can you add a short comment why updating current_frequency is needed? > Sure - I'll add a comment. If stat->current_frequency is not updated, the governor would always ask to set the max freq because the initial frequency was unknown to it. Reference - devfreq_simple_ondemand_func(...) > > Thanks, > Avri > Thanks, -asd -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, Linux Foundation Collaborative Project