Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2070309pxb; Thu, 11 Feb 2021 03:41:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLEABULuQy5vpMSYPjYXr/Olvz81Swk32NEWuBJ9q+z/E/RVWAnaXQonesVBObcXa9CkYc X-Received: by 2002:a17:906:e088:: with SMTP id gh8mr8034490ejb.294.1613043660299; Thu, 11 Feb 2021 03:41:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613043660; cv=none; d=google.com; s=arc-20160816; b=nw3w8MntliGn9VRIayZA0f4mHbGTge6a1R4xGHjgmymXKVKniTbWiyy8VFHf6TcYQ+ xriPF2+cKH9REUdKkUwgmsiAVHJWiAfGE5oMBILWpBbrEm5jfEblvlpYWwV2CMr1TuPC ZYmlGw6GWbJGuFJklJy6YHgDmWXWfi5MzoJWnj383NUFX2G/kfxWidGHiNofigcCUCIp X91xF6V6QyNwT5MbdKejsj5ZZ+zZaZ7QhGqI0WJeRAxZT0+jUomcCdrXRNZsXD3zJ4oS N/1IBQvJT/lISWsrtQ8AbtkwaZDLF+nslVE9S8pGEJs9fdBAwe8Ot3UhkpylmOr0Adnw oysQ== 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:references:cc :to:from:subject; bh=C8UsYrxiLFasl7cya6TzYV4WATxZm5kvqHW9qiQgKrQ=; b=mVkb6EPwyiU/L0mxglyGTdVZTzAB6wVV9zEx9aJ/KnhbltIduW+hJfHMsO5582KLGL Vjrzunf/KMEyEigDG/TqcKmxDAdVpSbe+g5Dh5ixOMo4VxLHU9eWxEp3Vm4QVSIdE7Kl x0qLdCAtbmwZSZFLrR1g4P3iqbh9yFHEEbr1Ors0fSI1Lv45rPF3H0Rx7HSwBtQj+5Tw +Nmgu+CFEmgzKjT8GsXpDv862nz7++3mPpaQ9m59LEQeIRVseOu1WmmcxPWcCmhlJc4t L8qCZlqRgbFy0JON08wy+eGtaO3cHDNww1e/o2u2rbOMSArgTUB6TK3dwyZDTUYwe5El mJLA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si3666766eje.486.2021.02.11.03.40.34; Thu, 11 Feb 2021 03:41:00 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231594AbhBKLh5 (ORCPT + 99 others); Thu, 11 Feb 2021 06:37:57 -0500 Received: from foss.arm.com ([217.140.110.172]:50132 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbhBKLIA (ORCPT ); Thu, 11 Feb 2021 06:08:00 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2467C31B; Thu, 11 Feb 2021 03:07:13 -0800 (PST) Received: from [10.57.13.164] (unknown [10.57.13.164]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7E5803F73B; Thu, 11 Feb 2021 03:07:10 -0800 (PST) Subject: Re: [RFC][PATCH 1/3] PM /devfreq: add user frequency limits into devfreq struct From: Lukasz Luba To: Chanwoo Choi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, vireshk@kernel.org, rafael@kernel.org, daniel.lezcano@linaro.org, Dietmar.Eggemann@arm.com, amitk@kernel.org, rui.zhang@intel.com, myungjoo.ham@samsung.com, kyungmin.park@samsung.com References: <20210126104001.20361-1-lukasz.luba@arm.com> <20210126104001.20361-2-lukasz.luba@arm.com> <5bd13e13-202f-d059-da29-f82806c33a38@arm.com> Message-ID: Date: Thu, 11 Feb 2021 11:07:08 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <5bd13e13-202f-d059-da29-f82806c33a38@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chanwoo, On 2/3/21 10:21 AM, Lukasz Luba wrote: > Hi Chanwoo, > > Thank you for looking at this. > > On 2/3/21 10:11 AM, Chanwoo Choi wrote: >> Hi Lukasz, >> >> When accessing the max_freq and min_freq at devfreq-cooling.c, >> even if can access 'user_max_freq' and 'lock' by using the 'devfreq' >> instance, >> I think that the direct access of variables >> (lock/user_max_freq/user_min_freq) >> of struct devfreq are not good. >> >> Instead, how about using the 'DEVFREQ_TRANSITION_NOTIFIER' >> notification with following changes of 'struct devfreq_freq'? > > I like the idea with devfreq notification. I will have to go through the > code to check that possibility. > >> Also, need to add codes into devfreq_set_target() for initializing >> 'new_max_freq' and 'new_min_freq' before sending the DEVFREQ_POSTCHANGE >> notification. >> >> diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h >> index 147a229056d2..d5726592d362 100644 >> --- a/include/linux/devfreq.h >> +++ b/include/linux/devfreq.h >> @@ -207,6 +207,8 @@ struct devfreq { >>   struct devfreq_freqs { >>          unsigned long old; >>          unsigned long new; >> +       unsigned long new_max_freq; >> +       unsigned long new_min_freq; >>   }; >> >> >> And I think that new 'user_min_freq'/'user_max_freq' are not necessary. >> You can get the current max_freq/min_freq by using the following steps: >> >>     get_freq_range(devfreq, &min_freq, &max_freq); >>     dev_pm_opp_find_freq_floor(pdev, &min_freq); >>     dev_pm_opp_find_freq_floor(pdev, &max_freq); >> >> So that you can get the 'max_freq/min_freq' and then >> initialize the 'freqs.new_max_freq and freqs.new_min_freq' >> with them as following: >> >> in devfreq_set_target() >>     get_freq_range(devfreq, &min_freq, &max_freq); >>     dev_pm_opp_find_freq_floor(pdev, &min_freq); >>     dev_pm_opp_find_freq_floor(pdev, &max_freq); >>     freqs.new_max_freq = min_freq; >>     freqs.new_max_freq = max_freq; >>     devfreq_notify_transition(devfreq, &freqs, DEVFREQ_POSTCHANGE); > > I will plumb it in and check that option. My concern is that function > get_freq_range() would give me the max_freq value from PM QoS, which > might be my thermal limit - lower that user_max_freq. Then I still > need > > I've been playing with PM QoS notifications because I thought it would > be possible to be notified in thermal for all new set values - even from > devfreq sysfs user max_freq write, which has value higher that the > current limit set by thermal governor. Unfortunately PM QoS doesn't > send that information by design. PM QoS also by desing won't allow > me to check first two limits in the plist - which would be thermal > and user sysfs max_freq. > > I will experiment with this notifications and share the results. > That you for your comments. I have experimented with your proposal. Unfortunately, the value stored in the pm_qos which is read by get_freq_range() is not the user max freq. It's the value from thermal devfreq cooling when that one is lower. Which is OK in the overall design, but not for my IPA use case. What comes to my mind is two options: 1) this patch proposal, with simple solution of two new variables protected by mutex, which would maintain user stored values 2) add a new notification chain in devfreq to notify about new user written value, to which devfreq cooling would register; that would allow devfreq cooling to get that value instantly and store locally What do you think Chanwoo? Regards, Lukasz