Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4123642pxu; Mon, 30 Nov 2020 18:39:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJybGz86t3DVgnKcVkx74g10flCb4xOnugR4yP/ZR4cfhmzuDil9Ga9i3rTkymsBtob75osX X-Received: by 2002:a05:6402:143a:: with SMTP id c26mr827807edx.131.1606790364105; Mon, 30 Nov 2020 18:39:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606790364; cv=none; d=google.com; s=arc-20160816; b=E6E6OYmsFzNteqz7UNoRz2LU9HRM1imBThIEb0DvG1OoshX+AFLURsSJyZ5qYrYC1k Q3z0b+qOj4ZVUU8pFfotYuBFdZR0WCftohOmDyiIOIg3Cyut5K0KZNeFLTLyY1PwAutZ bqOLw4PaqnHG3xXXAGjcis36TvVhkNf2dqio8FIn2LqlbSBhIBW7M5E08h51IeMqfrAC BDgSZkLGv6ZeGPidTKWBele6/oPpwXGJfFe19hBryWcDrFopE0YVWUdSJFoi1U8zJo5N K/5n9f5lDyujya7ENIo268woYe3EDsmXbDog4mVUUbLMLlyinAF7KxrTtIaXplcWsR47 hTUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dmarc-filter:sender:dkim-signature; bh=zDbLka9uUrfbZFvpBNQIhZzv3iWnZaNysnzWiwAqdzY=; b=x4S/shAvJnAsfVMowbDyV8uE8biuz1AdDAvjOSwkcWosoxGwhY8E+FT0d7xviy9tXQ y8oh1BaHEBq7Yqo2J90RiYtv9lW1bDXWNy9/sb3SRvdstUB3az+ge9+L2/f0VuCoOmVM oYqRakP28TGCVikHtCd1Fi9Xtk/REIGyYSonl+gVF9YPq8J74YwQ21Ufm+ph0RZgD8h5 h4sJZQNcwGYD1g91ROSouDyAcfg6rckMOmQxHhICPioRFyQzRDnFCujdKSVZEhnukTA0 kuaBWF+3SfNDJPPfswg0teBBN5JSTkuIPXXeOXMLV64J9JgFLnqVnOnQPQL1xqI1TSad 4X/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=S1nqbvv5; 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 a3si93776ejd.407.2020.11.30.18.39.01; Mon, 30 Nov 2020 18:39:24 -0800 (PST) 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=pass header.i=@mg.codeaurora.org header.s=smtp header.b=S1nqbvv5; 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 S1730872AbgK3Wzx (ORCPT + 99 others); Mon, 30 Nov 2020 17:55:53 -0500 Received: from m42-4.mailgun.net ([69.72.42.4]:29911 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730868AbgK3Wzv (ORCPT ); Mon, 30 Nov 2020 17:55:51 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1606776925; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=zDbLka9uUrfbZFvpBNQIhZzv3iWnZaNysnzWiwAqdzY=; b=S1nqbvv5Ru+9gePjUnEq3Xw9MdLLi/sT+zpnBMpYxWdt1V7c7FvSuerQs6ymhM2UEWWUIUKF TwnJqc9teg8y8VMxclEW6CoLfC5/mhmQYM2mU3NM/ZigBr3PGqm/gXqhYqb2U+EA9yrhZXL2 i8WdtKyn91n4ThnO4guC3Dz76Cw= X-Mailgun-Sending-Ip: 69.72.42.4 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-n03.prod.us-east-1.postgun.com with SMTP id 5fc5783f0f9adc18c7fdbb95 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 30 Nov 2020 22:54:55 GMT Sender: asutoshd=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id DFAB4C43465; Mon, 30 Nov 2020 22:54:54 +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=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.8.168] (cpe-70-95-149-85.san.res.rr.com [70.95.149.85]) (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 D4516C433C6; Mon, 30 Nov 2020 22:54:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D4516C433C6 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=fail smtp.mailfrom=asutoshd@codeaurora.org Subject: Re: [PATCH 1/1] scsi: ufs: Remove scale down gear hard code To: Can Guo , nguyenb@codeaurora.org, hongwus@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com Cc: Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Bart Van Assche , Satya Tangirala , open list References: <1606442334-22641-1-git-send-email-cang@codeaurora.org> From: "Asutosh Das (asd)" Message-ID: Date: Mon, 30 Nov 2020 14:54:52 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: <1606442334-22641-1-git-send-email-cang@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/26/2020 5:58 PM, Can Guo wrote: > Instead of making the scale down gear a hard code, make it a member of > ufs_clk_scaling struct. > > Signed-off-by: Can Guo > --- Reviewed-by: Asutosh Das > drivers/scsi/ufs/ufshcd.c | 12 +++++++----- > drivers/scsi/ufs/ufshcd.h | 2 ++ > 2 files changed, 9 insertions(+), 5 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 44254c9..1789df3 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -1100,7 +1100,6 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, > */ > static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up) > { > - #define UFS_MIN_GEAR_TO_SCALE_DOWN UFS_HS_G1 > int ret = 0; > struct ufs_pa_layer_attr new_pwr_info; > > @@ -1111,16 +1110,16 @@ static int ufshcd_scale_gear(struct ufs_hba *hba, bool scale_up) > memcpy(&new_pwr_info, &hba->pwr_info, > sizeof(struct ufs_pa_layer_attr)); > > - if (hba->pwr_info.gear_tx > UFS_MIN_GEAR_TO_SCALE_DOWN > - || hba->pwr_info.gear_rx > UFS_MIN_GEAR_TO_SCALE_DOWN) { > + if (hba->pwr_info.gear_tx > hba->clk_scaling.min_gear || > + hba->pwr_info.gear_rx > hba->clk_scaling.min_gear) { > /* save the current power mode */ > memcpy(&hba->clk_scaling.saved_pwr_info.info, > &hba->pwr_info, > sizeof(struct ufs_pa_layer_attr)); > > /* scale down gear */ > - new_pwr_info.gear_tx = UFS_MIN_GEAR_TO_SCALE_DOWN; > - new_pwr_info.gear_rx = UFS_MIN_GEAR_TO_SCALE_DOWN; > + new_pwr_info.gear_tx = hba->clk_scaling.min_gear; > + new_pwr_info.gear_rx = hba->clk_scaling.min_gear; > } > } > > @@ -1824,6 +1823,9 @@ static void ufshcd_init_clk_scaling(struct ufs_hba *hba) > if (!ufshcd_is_clkscaling_supported(hba)) > return; > > + if (!hba->clk_scaling.min_gear) > + hba->clk_scaling.min_gear = UFS_HS_G1; > + > INIT_WORK(&hba->clk_scaling.suspend_work, > ufshcd_clk_scaling_suspend_work); > INIT_WORK(&hba->clk_scaling.resume_work, > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 6f0f2d4..bdab23e 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -385,6 +385,7 @@ struct ufs_saved_pwr_info { > * @workq: workqueue to schedule devfreq suspend/resume work > * @suspend_work: worker to suspend devfreq > * @resume_work: worker to resume devfreq > + * @min_gear: lowest HS gear to scale down to > * @is_allowed: tracks if scaling is currently allowed or not > * @is_busy_started: tracks if busy period has started or not > * @is_suspended: tracks if devfreq is suspended or not > @@ -399,6 +400,7 @@ struct ufs_clk_scaling { > struct workqueue_struct *workq; > struct work_struct suspend_work; > struct work_struct resume_work; > + u32 min_gear; > bool is_allowed; > bool is_busy_started; > bool is_suspended; > -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, Linux Foundation Collaborative Project