Received: by 10.192.165.148 with SMTP id m20csp4986399imm; Tue, 24 Apr 2018 11:40:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/0jlMrIY5NEY4K/XGR1Aeruvue/3e1aMqV3pHCIiXqEaD4xbKKBGTZ/r8EFlkTj8dW67gK X-Received: by 2002:a17:902:69c5:: with SMTP id m5-v6mr25675192pln.358.1524595229581; Tue, 24 Apr 2018 11:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524595229; cv=none; d=google.com; s=arc-20160816; b=CWLATJSL0iaMPZ40zGRzvFk1STzRwG8gVEFeCU88jrSNmi7kRZn+P4Nwv9takqd4hG jJNH/pPG6843rhxTKvt/8J8OvfzkOoVG9rET84r06rWUmI075qTl7ldBm/XUHv0pgaCk gkY0hBob0cz8/maCIQ7e8sFk093e8ayM644er6IBT4LoSUmyEwFChrn+T4IgquZZxSb7 jAXkV5nMI0IxQhlZE1E6r3mE9L1qNCU/L4LQYaCNKiWvuIAbzsqIxxze/61sli3EXKp3 RF45lg7imBAcKrfUHyZLrrqSXFh/L5TLltiXVF+lRbzzOFPTuKK/03wxRpAlSGRwvSEQ D0/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=bPixiqBzmaviAZMX4AXCW+g2gwXv6UgI/4u22ByMcWg=; b=PSb7hYeDHBY8ILhTEYIu1dbGA5eTBfYSeCyV1yRitEA3HPa9UtFx14VNTsYpxSb7RE KO7+eT9wPmOtNMjbdJ5y2hVu5JAIeXbD/ZN0zz+2X79Eu0qSsPd5a/0LoBX9dF/L9slg xhy+/RwqWQ7Ox98Q3F9LBaYoXcvjvUuJJ0bZHCUEs9+NGcNeVZnpxDl3cjj6cHrsStUt gNAgU1hYsqBcW1i/5XbjVe52VzQPDLiT87ZzSyvm3oJtwYGGGE5vcjy3S4EBShI0CdjN v2elMgYHOMN5WuGmum4iq/x0uYnJqLaVI551atdETub0SOlQ+Pijw9EHwbPMilHFtamN GkuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G/locyUB; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w15-v6si14756265plq.183.2018.04.24.11.40.14; Tue, 24 Apr 2018 11:40:29 -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=@linaro.org header.s=google header.b=G/locyUB; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751129AbeDXSjI (ORCPT + 99 others); Tue, 24 Apr 2018 14:39:08 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:32802 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750772AbeDXSjD (ORCPT ); Tue, 24 Apr 2018 14:39:03 -0400 Received: by mail-pg0-f68.google.com with SMTP id i194so11485585pgd.0 for ; Tue, 24 Apr 2018 11:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bPixiqBzmaviAZMX4AXCW+g2gwXv6UgI/4u22ByMcWg=; b=G/locyUBTjpSu+IKmYiXy2NPEelwhB5/zaiAVdqUvMHx5h//ctP8MZt8/6HsokdI7R Hy7i0Q+YKJV068vXuvrrlVKzJXoqopcJzQQLONQ1wHojLsNmuV+14lm25D+FSiIZOj5r MCPy24tVCTtd8/LkYJq09Uq+2QFB8SsNBimFk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bPixiqBzmaviAZMX4AXCW+g2gwXv6UgI/4u22ByMcWg=; b=UsbT2QjRGIe6+btL9ddGmIxWim7IZbAXtQ4UD0rivJ7pJhTa0d8EMUTwBV9kiwkXH6 4T7A5z82jYXTlyDnAS9IurojVHlT/UlsO86UOewzIYhCjccfQZ2pP+A0tiG/a6dGrfYG W0489EGxMV5wEh+vK2mtlNK+tPjAFSJsHsRJLXEdZUj0xk+aTKo5enob7N2Uw2Vop6V4 pNsQEuucdF46BUsJ5Kav9waSI9dU+O9efoRg2uuepRVgDAMavHq026J0zJGa5HS+avvV fQuo8piBZTXkFERBT1pf2x/gAltXGz5YMnm68v3qyic8llljDiZMGfvYunZiBnsbdxCE G2Eg== X-Gm-Message-State: ALQs6tDk8bJ0bCVwKVk5GPgZD8Sm4h6IrCx6fMA04X1nnlLmSByF4pk6 4p6+kH3/SucVks0wBxU/QlBdsJeG1p8= X-Received: by 10.99.95.13 with SMTP id t13mr21551947pgb.145.1524595142759; Tue, 24 Apr 2018 11:39:02 -0700 (PDT) Received: from minitux (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id b89sm1938399pfd.85.2018.04.24.11.39.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Apr 2018 11:39:02 -0700 (PDT) Date: Tue, 24 Apr 2018 11:38:59 -0700 From: Bjorn Andersson To: Chanwoo Choi Cc: MyungJoo Ham , Kyungmin Park , Vinayak Holikatti , "Martin K. Petersen" , 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 1/3] PM / devfreq: Actually support providing freq_table Message-ID: <20180424183859.GC18510@minitux> References: <20180424002016.9205-1-bjorn.andersson@linaro.org> <20180424002016.9205-2-bjorn.andersson@linaro.org> <5ADE9AE6.9090601@samsung.com> <20180424052916.GD2052@tuxbook-pro> <5ADEDC1A.2000101@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5ADEDC1A.2000101@samsung.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 24 Apr 00:26 PDT 2018, Chanwoo Choi wrote: > Hi, > > On 2018??? 04??? 24??? 14:29, Bjorn Andersson wrote: > > On Mon 23 Apr 19:48 PDT 2018, Chanwoo Choi wrote: > > > >> Hi, > >> > >> On 2018??? 04??? 24??? 09:20, Bjorn Andersson wrote: > >>> The code in devfreq_add_device() handles the case where a freq_table is > >>> passed by the client, but then requests min and max frequences from > >>> the, in this case absent, opp tables. > >>> > >>> Read the min and max frequencies from the frequency table, which has > >>> been built from the opp table if one exists, instead of querying the > >>> opp table. > >>> > >>> Signed-off-by: Bjorn Andersson > >>> --- > >>> > >>> An alternative approach is to clarify in the devfreq code that it's not > >>> possible to pass a freq_table and then in patch 3 create an opp table for the > >>> device in runtime; although the error handling of this becomes non-trivial. > >>> > >>> Transitioning the UFSHCD to use opp tables directly is hindered by the fact > >>> that the Qualcomm UFS hardware has two different clocks that needs to be > >>> running at different rates, so we would need a way to describe the two rates in > >>> the opp table. (And would force us to change the DT binding) > >>> > >>> drivers/devfreq/devfreq.c | 22 ++++------------------ > >>> 1 file changed, 4 insertions(+), 18 deletions(-) > >>> > >>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c > >>> index fe2af6aa88fc..086ced50a13d 100644 > >>> --- a/drivers/devfreq/devfreq.c > >>> +++ b/drivers/devfreq/devfreq.c > >>> @@ -74,30 +74,16 @@ static struct devfreq *find_device_devfreq(struct device *dev) > >>> > >>> static unsigned long find_available_min_freq(struct devfreq *devfreq) > >>> { > >>> - struct dev_pm_opp *opp; > >>> - unsigned long min_freq = 0; > >>> - > >>> - opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &min_freq); > >>> - if (IS_ERR(opp)) > >>> - min_freq = 0; > >>> - else > >>> - dev_pm_opp_put(opp); > >>> + struct devfreq_dev_profile *profile = devfreq->profile; > >>> > >>> - return min_freq; > >>> + return profile->freq_table[0]; > >> > >> It is wrong. The thermal framework support the devfreq-cooling device > >> which uses the dev_pm_opp_enable/disable(). > >> > > > > Okay, that makes sense. So rather than registering a custom freq_table I > > should register the min and max frequency using dev_pm_opp_add(). > > Thanks. > > > > >> In order to find the correct available min frequency, > >> the devfreq have to use the OPP function instead of using the first entry > >> of the freq_table array. > >> > > > > Based on this there seems to be room for cleaning out the freq_table > > from devfreq, to reduce the confusion. I will review this further. > > Actually, devfreq must need to have the freq_table[] array. But, freq_table[] > array should be handled in the devfreq core. Now, the devfreq device drivers can > touch the freq_table. I think it is not good. > > There is a reason why we have to maintain the freq_table[] as the internal variable. > OPP doesn't provide the OPP API which get the all registered frequencies. > If devfreq-cooling device disables the specific frequency by using dev_pm_oppdisable(), > the user of OPP interface can not get the disabled frequency list. > So, I maintain the freq_table even if using the OPP interface. > Thanks for the clarification, I see some possibilities for improving this but it makes sense. > And, devfreq-cooling device uses the freq_table directly because > released MALi driver from ARM initializes the freq_table list > directly. > Forgive me if I misunderstand this, but isn't this exactly what I'm trying to do in patch 3? Which stopped working back in v4.15-rc1, with the introduction of f1d981eaecf8 ("PM / devfreq: Use the available min/max frequency"). > I have no any objection for refactoring. Just I'm sharing the issue > and current status. > Thanks for sharing the current status and helping me understand how to properly use devfreq. Regards, Bjorn