Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2683684ybl; Mon, 20 Jan 2020 07:28:54 -0800 (PST) X-Google-Smtp-Source: APXvYqxtMfE3Wbo3Sv8HD88FvghEhpcOxgguslmIYUilbBkUmufOqnJtrXKgEPCeVQtqDx24OFQo X-Received: by 2002:a9d:6c01:: with SMTP id f1mr15860558otq.133.1579534133882; Mon, 20 Jan 2020 07:28:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579534133; cv=none; d=google.com; s=arc-20160816; b=e3GcKVHmhvWCfZSML7w/tZJn0JyWbDGMf3s3kDDHlfCEjtqAU5nVJs7/2yMNpDnghl YFuCVx5sqcDb1t274IVC9NazxL3qTIp52PBEh30iMpe6WGr2go+otSGHvHKBn5PFe1NB ZA+6vaH1phvULfrKD+9cTmpwKygl1E1ECfR5E/kqeX1675AmnKN65v7lkiz+mgxVZZJ5 sBiwANdZEPl8j+aw0x+9zzELuUbo8fGtkjuB4UeGdi+2rCaNqqcaWpIWnvI6QziVBjhV 0L6FSmfR//b/coF73AZqqu36vO12fQzenkyuet4ZC/3PjTtNgS6Ssdxm8b3MMWJVe0MO t4Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=3cmfvxxQdo+LR5gAKe4iB0vJJ2mWBCDZOW+oTNWy8cc=; b=V2SlBXlRU+/GXg+rod2I1DnjqzuLtMvAryVryPqLdVc0UhfDuUjsqEZUZjvtxc0s03 l0vxAd+qjz2+q+/SMkk2BD7ObJxuqTFbmezlLWZMH39Y+mcKnt8jd4yL5c8hzd3UgVH4 I/JlsfxRLWPjwsXdiGPPeqvWwMuGqoabbuVGIIq6xQKcASXwD6kVLYQDokpeSAANm2N3 vvxYEWUbDH/UGwPL0OUr0BT/FjBAU95HgzmKpPhakNdVIwcCwnebIo93f4nAQg0wb+QK pofNehvD8xLUO+Ax753eaK/is4o5OOFHjb1I7HnXaiugpMoFzVzmHciQ7iNzkMYE8U58 XbLw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h7si20920051otk.86.2020.01.20.07.28.40; Mon, 20 Jan 2020 07:28:53 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727031AbgATP1n (ORCPT + 99 others); Mon, 20 Jan 2020 10:27:43 -0500 Received: from foss.arm.com ([217.140.110.172]:33662 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbgATP1n (ORCPT ); Mon, 20 Jan 2020 10:27:43 -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 154E130E; Mon, 20 Jan 2020 07:27:42 -0800 (PST) Received: from [10.37.12.169] (unknown [10.37.12.169]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5FF413F52E; Mon, 20 Jan 2020 07:27:32 -0800 (PST) Subject: Re: [PATCH 1/4] PM / EM: and devices to Energy Model To: Dietmar Eggemann , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-imx@nxp.com Cc: Morten.Rasmussen@arm.com, Chris.Redpath@arm.com, ionela.voinescu@arm.com, javi.merino@arm.com, cw00.choi@samsung.com, b.zolnierkie@samsung.com, rjw@rjwysocki.net, sudeep.holla@arm.com, viresh.kumar@linaro.org, nm@ti.com, sboyd@kernel.org, rui.zhang@intel.com, amit.kucheria@verdurent.com, daniel.lezcano@linaro.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, rostedt@goodmis.org, qperret@google.com, bsegall@google.com, mgorman@suse.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, kernel@pengutronix.de, khilman@kernel.org, agross@kernel.org, bjorn.andersson@linaro.org, robh@kernel.org, matthias.bgg@gmail.com, steven.price@arm.com, tomeu.vizoso@collabora.com, alyssa.rosenzweig@collabora.com, airlied@linux.ie, daniel@ffwll.ch, patrick.bellasi@matbug.net References: <20200116152032.11301-1-lukasz.luba@arm.com> <20200116152032.11301-2-lukasz.luba@arm.com> <17b77e0c-9455-0479-d37b-c57717c784c7@arm.com> From: Lukasz Luba Message-ID: <7d620ad0-9baa-7c0b-d596-a534bccaad64@arm.com> Date: Mon, 20 Jan 2020 15:27:30 +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: <17b77e0c-9455-0479-d37b-c57717c784c7@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dietmar, On 1/20/20 2:53 PM, Dietmar Eggemann wrote: > On 16/01/2020 16:20, lukasz.luba@arm.com wrote: >> From: Lukasz Luba >> >> Add support of other devices into the Energy Model framework not only the >> CPUs. Change the interface to be more unified which can handle other >> devices as well. > > [...] > >> -The source of the information about the power consumed by CPUs can vary greatly >> +The source of the information about the power consumed by devices can vary greatly >> from one platform to another. These power costs can be estimated using >> devicetree data in some cases. In others, the firmware will know better. >> Alternatively, userspace might be best positioned. And so on. In order to avoid >> @@ -26,7 +28,7 @@ framework, and interested clients reading the data from it:: >> | Thermal (IPA) | | Scheduler (EAS) | | Other | >> +---------------+ +-----------------+ +---------------+ >> | | em_pd_energy() | >> - | | em_cpu_get() | >> + | em_dev_get() | em_cpu_get() | > > Looked really hard but can't find a em_dev_get() in the code? You mean > em_get_pd() ? And why em_get_pd() and not em_pd_get()? It was it the old implementation, I will remove 'em_dev_get()' from the doc. The em_pd_get() is OK for me, I can change it. > >> +---------+ | +---------+ >> | | | >> v v v >> @@ -47,12 +49,12 @@ framework, and interested clients reading the data from it:: >> | Device Tree | | Firmware | | ? | >> +--------------+ +---------------+ +--------------+ > > [...] > >> +There is two API functions which provide the access to the energy model: >> +em_cpu_get() which takes CPU id as an argument and em_dev_get() with device >> +pointer as an argument. It depends on the subsystem which interface it is >> +going to use. > > Would be really nice if this wouldn't be required. We should really aim > for 1 framework == 1 set of interfaces. > > What happens if someone calls em_get_pd() on a CPU EM? > > E.g: > > static struct perf_domain *pd_init(int cpu) > { > - struct em_perf_domain *obj = em_cpu_get(cpu); > + struct device *dev = get_cpu_device(cpu); > + struct em_perf_domain *obj = em_pd_get(dev); > struct perf_domain *pd; > > Two versions of one functionality will confuse API user from the > beginning ... Right, I could modify the pd_init code to use one 'em_get_pd' API and remove the 'em_cpu_get'. > > [...] > >> +enum em_type { >> + EM_SIMPLE, >> + EM_CPU, >> +}; > > s/EM_SIMPLE/EM_DEV ? > > Right now I only see energy models and _one_ specific type (the CPU EM). > So a tag 'is a CPU EM' would suffice. No need for EM_SIMPE ... The EM_SIMPLE is set in the em_register_perf_domain() to distinguish CPU device which has populated 'priv' pointer and set EM_CPU. We can just rely on 'priv == NULL' to check if we are dealing with a CPU EM. Do you prefer this approach and get rid of em_type? Then the code would look like: if (em_pd->priv) seq_puts(s, "EM_CPU\n"); else seq_puts(s, "EM_SIMPLE\n"); Regards, Lukasz > > [...] >