From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6534CD1284 for ; Tue, 9 Apr 2024 14:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=grnEsuZw02591+o8JlKViaCWEJ1CQsPrvTIBFVxEJAI=; b=OyvDVygHDKtidQ XOKYOihlcMvt7qmVDZmLBGXB/xZ2hgEBzbI+oDAcZgE47uwvNvY/ekkAz9+bcCz1nUmQQq4ommYO8 6oq91oXxxra0+5EnJ1u3dZvbu49OdWSb1FM6p0f/v7JwwZXFdKSRgUimr+jF6MgQ8OZ+5FP6Ri5RX CV34SzbalU8+y+ytLui4WHk1ezFUwHG2HWpiNgpgs4A8ew9rbjOiU5Zn3ywU0142iDb791aKGEKXm iAAHEXkLGKvnTYgLdYHMXqgZ6ouoWQCSYcgYfYOenwg+LlVI4stw/Q0uNa4K1J09YEpVFPrnH49v1 qyC3I3IBG82a9G1aW8Bg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruCls-00000002Vsx-3s8J; Tue, 09 Apr 2024 14:48:25 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruClo-00000002VpP-33n6 for linux-arm-kernel@lists.infradead.org; Tue, 09 Apr 2024 14:48:22 +0000 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 1E354139F; Tue, 9 Apr 2024 07:48:47 -0700 (PDT) Received: from [10.57.19.31] (unknown [10.57.19.31]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 48B533F766; Tue, 9 Apr 2024 07:48:15 -0700 (PDT) Message-ID: <08bff6ab-dcdc-42b6-b8ad-5938f0119385@arm.com> Date: Tue, 9 Apr 2024 15:47:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] PM: EM: Add min/max available performance state limits To: Lukasz Luba , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: dietmar.eggemann@arm.com, linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, cristian.marussi@arm.com, linux-samsung-soc@vger.kernel.org, rafael@kernel.org, viresh.kumar@linaro.org, quic_sibis@quicinc.com References: <20240403162315.1458337-1-lukasz.luba@arm.com> <20240403162315.1458337-2-lukasz.luba@arm.com> Content-Language: en-US From: Hongyan Xia In-Reply-To: <20240403162315.1458337-2-lukasz.luba@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240409_074821_343348_6A9D8B29 X-CRM114-Status: GOOD ( 18.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 03/04/2024 17:23, Lukasz Luba wrote: > [...] > > diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c > index 927cc55ba0b3d..1a8b394251cb2 100644 > --- a/kernel/power/energy_model.c > +++ b/kernel/power/energy_model.c > @@ -628,6 +628,8 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, > goto unlock; > > dev->em_pd->flags |= flags; > + dev->em_pd->min_ps = 0; > + dev->em_pd->max_ps = nr_states - 1; > > em_cpufreq_update_efficiencies(dev, dev->em_pd->em_table->state); > > @@ -856,3 +858,49 @@ int em_dev_update_chip_binning(struct device *dev) > return em_recalc_and_update(dev, pd, em_table); > } > EXPORT_SYMBOL_GPL(em_dev_update_chip_binning); > + > + > +/** > + * em_update_performance_limits() - Update Energy Model with performance > + * limits information. > + * @pd : Performance Domain with EM that has to be updated. > + * @freq_min_khz : New minimum allowed frequency for this device. > + * @freq_max_khz : New maximum allowed frequency for this device. > + * > + * This function allows to update the EM with information about available > + * performance levels. It takes the minimum and maximum frequency in kHz > + * and does internal translation to performance levels. > + * Returns 0 on success or -EINVAL when failed. > + */ > +int em_update_performance_limits(struct em_perf_domain *pd, > + unsigned long freq_min_khz, unsigned long freq_max_khz) > +{ > + struct em_perf_state *table; > + int min_ps = -1; > + int max_ps = -1; > + int i; > + > + if (!pd) > + return -EINVAL; > + > + rcu_read_lock(); > + table = em_perf_state_from_pd(pd); > + > + for (i = 0; i < pd->nr_perf_states; i++) { > + if (freq_min_khz == table[i].frequency) > + min_ps = i; > + if (freq_max_khz == table[i].frequency) > + max_ps = i; > + } > + rcu_read_unlock(); > + > + /* Only update when both are found and sane */ > + if (min_ps < 0 || max_ps < 0 || max_ps < min_ps) > + return -EINVAL; > + > + pd->min_ps = min_ps; > + pd->max_ps = max_ps; Are we sure we are protected against multiple simultaneous updates? Or is this a concern for the caller? The rest of the patch LGTM. > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(em_update_performance_limits); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel