Received: by 10.192.165.148 with SMTP id m20csp3786851imm; Mon, 7 May 2018 19:52:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrtsWRqettGkFPBK6dulPU40xlNXs04YoEf2AY4nq5atRsiA2cFYjPrzQIMWTztOs4CyEZv X-Received: by 10.98.211.143 with SMTP id z15mr38374561pfk.100.1525747922459; Mon, 07 May 2018 19:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525747922; cv=none; d=google.com; s=arc-20160816; b=hfx4vOK1S592dda6znG3Qa/kbZBpi+mMnOPq2IojdkFpVrdGG8iyAlYm+Hvf2SbPDg QnHVA6JwvNkqQwwsRrEe4sG10Zd70VcmKAkRKV+5mETvqRN8cm1v6c/RMhu6cYobTY1P BqMTgNN8OtiV08b/8Op34aBUEOtYWEh8ADg813nFhVudGpTqXugjlD55tATSPtMyYzB/ P9Vd35hrxGxxR0FXeAIu93VJWIk1/8XVgAUUZjmfUO4m4ikOkpv4/ypOqxB+AnusBgKa wvi2GjSsYnppu6i1GpU20/XW5OxoTk6x9+EeR+6Xwsf7bQSWsd7eW7kAmK1bgttBAyA3 58bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type :in-reply-to:subject:cc:to:user-agent:organization:from:date :message-id:content-transfer-encoding:mime-version:dkim-signature :dkim-filter:arc-authentication-results; bh=a1VuLNic/2LFq06uhDomyOczFSMttYzMby8vU9KvYcw=; b=iZ+WygRrnCJzpem1SRyHiEHLL8pUK5N9Lr1EhEElaLtLff3tg8QXgNicW4KmqGlvCF hbFeQmivVzlSqVbW2dLbEnR/OJKk3rssuvtS8FwuFYOafKIx6ZlVi7/ZYcKIYj53cSYU ZfapUfdUT607FszylOxuc4ZvM8Wq1b+pHqfiPrkdi14Tg3WvD87zvvcgsGF6j9mcPNdj occegTheukj6jfLei0x2HZcl7NEsMBDhdaJwvb6VZD+xSWMGfsbfoixD3IGoXPAe7xHT YV1gqQk5oLQDTHKNA5Xuo2U+12z3Fjtl4zjWtb0FfABw9KnK62FKYhAk0THfQmqUqTL2 IsIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=kElj/2Vf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7-v6si18832406pgd.96.2018.05.07.19.51.47; Mon, 07 May 2018 19:52:02 -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=@samsung.com header.s=mail20170921 header.b=kElj/2Vf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753885AbeEHCvi (ORCPT + 99 others); Mon, 7 May 2018 22:51:38 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:56784 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753529AbeEHCvf (ORCPT ); Mon, 7 May 2018 22:51:35 -0400 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180508025133epoutp0398d93c30ec2382dc9f0c6d986b635ab9~si6ABx1YB0389703897epoutp035; Tue, 8 May 2018 02:51:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180508025133epoutp0398d93c30ec2382dc9f0c6d986b635ab9~si6ABx1YB0389703897epoutp035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1525747893; bh=a1VuLNic/2LFq06uhDomyOczFSMttYzMby8vU9KvYcw=; h=Date:From:To:Cc:Subject:In-reply-to:References:From; b=kElj/2VfYqKoYIN9ZZoUtkw1pzvR7QA2L3zH4pTdS2g9ye4L7T6Le+ad0nGrMOMJw 6XumJLCuKpp3VgDKlU/DA4XWrOq7xx0jfHld4IJ5peCU/eoM9ROuTAn6jJZ6/uEFxK 1SGVMSul3vhLJn9++4NHtAkR0ATFmyZh8IKBmlt0= Received: from epsmges2p2.samsung.com (unknown [182.195.40.154]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20180508025130epcas1p35a5fa73ca4943347e376a42d8a09a32b~si59ODrLc0998209982epcas1p3N; Tue, 8 May 2018 02:51:30 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 82.A9.04132.1B011FA5; Tue, 8 May 2018 11:51:29 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20180508025129epcas2p1e836dec99d2209af4b3dd4fb15ee97c2~si58kTjBx0821208212epcas2p1S; Tue, 8 May 2018 02:51:29 +0000 (GMT) X-AuditID: b6c32a46-145ff70000001024-2d-5af110b112d3 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 6F.BF.03817.1B011FA5; Tue, 8 May 2018 11:51:29 +0900 (KST) MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset="UTF-8" Received: from [10.113.63.77] by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P8E00GV02LS5450@mmp2.samsung.com>; Tue, 08 May 2018 11:51:29 +0900 (KST) Message-id: <5AF110B0.1030206@samsung.com> Date: Tue, 08 May 2018 11:51:28 +0900 From: Chanwoo Choi Organization: Samsung Electronics User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 To: Bjorn Andersson , Vinayak Holikatti , "Martin K. Petersen" Cc: MyungJoo Ham , Kyungmin Park , linux-scsi@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Vivek Gautam Subject: Re: [PATCH v2 2/2] scsi: ufs: Use freq table with devfreq In-reply-to: <20180504224427.32606-3-bjorn.andersson@linaro.org> X-Brightmail-Tracker: H4sIAAAAAAAAA01Sa0gUURT27qyzo7R1W7UuSmYT/VBw20erY2aZiWxUID0gDFlHHXztw3ZW qSBZ/ZFiPjOhtjINyfCBKT7WR5mraFpKpGn00F5aRJYimGZFMztG/brf+c53zrnn4xCYrAj3 JlKMFsZspPUk7i5u6/PXBDbBhRhFY2so9ajnq5gayfkioUp7RiTUWOd1nFos7AfUxUk7TtUM /hZRL7Pv4JS96hz1cMWOhbtrx4oKRdoO22uJ9tVEN65dmHkh1ha11ALtYrNvNB7D7Elm6ETG 7McYE0yJKcakMPLQMd0BnSZIoQxUhlDBpJ+RNjBhZOTh6MCoFD33M9Ivk9ZncFQ0zbLkzr17 zKYMC+OXbGItYeQppVIlVyqC5SoV96pjd6s0nCSOSW7oCkpvJM8U9FJWMO+TD9wIBHehgWsP xPnAnZBBO0C3vxa7CsF3gPLu8xlBNZT9ExcSdwF6sfwO4xNSuBEtl01xIoLA4FbU/zSNpzHo j1q7GiU8lsHXAM2vHOclUhiA5qY38bQY7kBT32ZwHuMc3fPpuRNvgNvQs+X3gMde8CTquLkk 4cd6wlKAisqvivgAg6sA1cxVOis8YARaHP3lHOYGw9F163unCMFvOHLYrmHCBpHI+rJ9DXug z4MtEgH7oNnaJiAU5AKUe68CE4LLAI1OTokElRrNVuWLhN3Wo7w+fhzB8VKUd0EmSLToyvCr tab7UdVkISbYNQTQ2952S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cLi+p1zy4Vz3W/MNhq+k/OWt1fYHzyJzXuv8uX7 e6wkFDTv7IkzcppcpdAw/aO5X56RqPijeJZXPz4ZOa/fydq38kXGvwc3gn4Gd6rsyWE2epDF 56LEUpyRaKjFXFScCAC5pz6+gQIAAA== X-CMS-MailID: 20180508025129epcas2p1e836dec99d2209af4b3dd4fb15ee97c2 X-Msg-Generator: CA CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180504224448epcas4p14166331ab890398af7fedab3b0cbb3b1 X-RootMTR: 20180504224448epcas4p14166331ab890398af7fedab3b0cbb3b1 References: <20180504224427.32606-1-bjorn.andersson@linaro.org> <20180504224427.32606-3-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2018년 05월 05일 07:44, 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 as opp levels > and use these to determine if we're trying to step up or down. > > Signed-off-by: Bjorn Andersson > --- > > Chances since v1: > - Register min_freq and max_freq as opp levels. > - Unregister opp levels on removal, to make e.g. probe defer working > > drivers/scsi/ufs/ufshcd.c | 47 +++++++++++++++++++++++++++++++++------ > 1 file changed, 40 insertions(+), 7 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 2253f24309ec..257614b889bd 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(clk_list, 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,16 +1260,29 @@ static struct devfreq_dev_profile ufs_devfreq_profile = { > > static int ufshcd_devfreq_init(struct ufs_hba *hba) > { > + struct list_head *clk_list = &hba->clk_list_head; > + struct ufs_clk_info *clki; > struct devfreq *devfreq; > int ret; > > - devfreq = devm_devfreq_add_device(hba->dev, > + /* Skip devfreq if we don't have any clocks in the list */ > + if (list_empty(clk_list)) > + return 0; > + > + clki = list_first_entry(clk_list, struct ufs_clk_info, list); > + dev_pm_opp_add(hba->dev, clki->min_freq, 0); > + dev_pm_opp_add(hba->dev, clki->max_freq, 0); > + > + devfreq = devfreq_add_device(hba->dev, > &ufs_devfreq_profile, > "simple_ondemand", > NULL); > if (IS_ERR(devfreq)) { > ret = PTR_ERR(devfreq); > dev_err(hba->dev, "Unable to register with devfreq %d\n", ret); > + > + dev_pm_opp_remove(hba->dev, clki->min_freq); > + dev_pm_opp_remove(hba->dev, clki->max_freq); > return ret; > } > > @@ -1275,6 +1291,22 @@ static int ufshcd_devfreq_init(struct ufs_hba *hba) > return 0; > } > > +static void ufshcd_devfreq_remove(struct ufs_hba *hba) > +{ > + struct list_head *clk_list = &hba->clk_list_head; > + struct ufs_clk_info *clki; > + > + if (!hba->devfreq) > + return; > + > + devfreq_remove_device(hba->devfreq); > + hba->devfreq = NULL; > + > + clki = list_first_entry(clk_list, struct ufs_clk_info, list); > + dev_pm_opp_remove(hba->dev, clki->min_freq); > + dev_pm_opp_remove(hba->dev, clki->max_freq); > +} > + > static void __ufshcd_suspend_clkscaling(struct ufs_hba *hba) > { > unsigned long flags; > @@ -6966,6 +6998,7 @@ static void ufshcd_hba_exit(struct ufs_hba *hba) > if (hba->devfreq) > ufshcd_suspend_clkscaling(hba); > destroy_workqueue(hba->clk_scaling.workq); > + ufshcd_devfreq_remove(hba); > } > ufshcd_setup_clocks(hba, false); > ufshcd_setup_hba_vreg(hba, false); > For using OPP entries for devfreq: Reviewed-by: Chanwoo Choi -- Best Regards, Chanwoo Choi Samsung Electronics