linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gautham R Shenoy <ego@linux.vnet.ibm.com>
To: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Cc: Daniel Axtens <dja@axtens.net>,
	mpe@ellerman.id.au, linux-kernel@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, ego@linux.vnet.ibm.com
Subject: Re: [PATCH] powernv: powercap: Add hard minimum powercap
Date: Thu, 28 Feb 2019 15:22:00 +0530	[thread overview]
Message-ID: <20190228095200.GB24751@in.ibm.com> (raw)
In-Reply-To: <57fc8253-c5c3-6103-77cd-34aa4ec250a3@linux.vnet.ibm.com>

Hi Shilpa,

On Thu, Feb 28, 2019 at 11:25:25AM +0530, Shilpasri G Bhat wrote:
> Hi,
> 
> On 02/28/2019 10:14 AM, Daniel Axtens wrote:
> > Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> writes:
> > 
> >> In POWER9, OCC(On-Chip-Controller) provides for hard and soft system
> >> powercapping range. The hard powercap range is guaranteed while soft
> >> powercap may or may not be asserted due to various power-thermal
> >> reasons based on system configuration and workloads. This patch adds
> >> a sysfs file to export the hard minimum powercap limit to allow the
> >> user to set the appropriate powercap value that can be managed by the
> >> system.
> > 
> > Maybe it's common terminology and I'm just not aware of it, but what do
> > you mean by "asserted"? It doesn't appear elsewhere in the documentation
> > you're patching, and it's not a use of assert that I'm familiar with...
> > 
> > Regards,
> > Daniel
> > 
> 
> I meant to say powercap will not be assured in the soft powercap range, i.e,
> system may or may not be throttled of CPU frequency to remain within the powercap.
> 
> I can reword the document and commit message.

I agree with Daniel. How about replacing "asserted" with "enforced by
the OCC"?


> 
> Thanks and Regards,
> Shilpa

--
Thanks and Regards
gautham.

> 
> >>
> >> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
> >> ---
> >>  .../ABI/testing/sysfs-firmware-opal-powercap       | 10 ++++
> >>  arch/powerpc/platforms/powernv/opal-powercap.c     | 66 +++++++++-------------
> >>  2 files changed, 37 insertions(+), 39 deletions(-)
> >>
> >> diff --git a/Documentation/ABI/testing/sysfs-firmware-opal-powercap b/Documentation/ABI/testing/sysfs-firmware-opal-powercap
> >> index c9b66ec..65db4c1 100644
> >> --- a/Documentation/ABI/testing/sysfs-firmware-opal-powercap
> >> +++ b/Documentation/ABI/testing/sysfs-firmware-opal-powercap
> >> @@ -29,3 +29,13 @@ Description:	System powercap directory and attributes applicable for
> >>  		  creates a request for setting a new-powercap. The
> >>  		  powercap requested must be between powercap-min
> >>  		  and powercap-max.
> >> +
> >> +What:		/sys/firmware/opal/powercap/system-powercap/powercap-hard-min
> >> +Date:		Feb 2019
> >> +Contact:	Linux for PowerPC mailing list <linuxppc-dev@ozlabs.org>
> >> +Description:	Hard minimum powercap
> >> +
> >> +		This file provides the hard minimum powercap limit in
> >> +		Watts. The powercap value above hard minimum is always
> >> +		guaranteed to be asserted and the powercap value below
> >> +		the hard minimum limit may or may not be guaranteed.
> >> diff --git a/arch/powerpc/platforms/powernv/opal-powercap.c b/arch/powerpc/platforms/powernv/opal-powercap.c
> >> index d90ee4f..38408e7 100644
> >> --- a/arch/powerpc/platforms/powernv/opal-powercap.c
> >> +++ b/arch/powerpc/platforms/powernv/opal-powercap.c
> >> @@ -139,10 +139,24 @@ static void powercap_add_attr(int handle, const char *name,
> >>  	attr->handle = handle;
> >>  	sysfs_attr_init(&attr->attr.attr);
> >>  	attr->attr.attr.name = name;
> >> -	attr->attr.attr.mode = 0444;
> >> +
> >> +	if (!strncmp(name, "powercap-current", strlen(name))) {
> >> +		attr->attr.attr.mode = 0664;
> >> +		attr->attr.store = powercap_store;
> >> +	} else {
> >> +		attr->attr.attr.mode = 0444;
> >> +	}
> >> +
> >>  	attr->attr.show = powercap_show;
> >>  }
> >>  
> >> +static const char * const powercap_strs[] = {
> >> +	"powercap-max",
> >> +	"powercap-min",
> >> +	"powercap-current",
> >> +	"powercap-hard-min",
> >> +};
> >> +
> >>  void __init opal_powercap_init(void)
> >>  {
> >>  	struct device_node *powercap, *node;
> >> @@ -167,60 +181,34 @@ void __init opal_powercap_init(void)
> >>  
> >>  	i = 0;
> >>  	for_each_child_of_node(powercap, node) {
> >> -		u32 cur, min, max;
> >> -		int j = 0;
> >> -		bool has_cur = false, has_min = false, has_max = false;
> >> +		u32 id;
> >> +		int j, count = 0;
> >>  
> >> -		if (!of_property_read_u32(node, "powercap-min", &min)) {
> >> -			j++;
> >> -			has_min = true;
> >> -		}
> >> -
> >> -		if (!of_property_read_u32(node, "powercap-max", &max)) {
> >> -			j++;
> >> -			has_max = true;
> >> -		}
> >> +		for (j = 0; j < ARRAY_SIZE(powercap_strs); j++)
> >> +			if (!of_property_read_u32(node, powercap_strs[j], &id))
> >> +				count++;
> >>  
> >> -		if (!of_property_read_u32(node, "powercap-current", &cur)) {
> >> -			j++;
> >> -			has_cur = true;
> >> -		}
> >> -
> >> -		pcaps[i].pattrs = kcalloc(j, sizeof(struct powercap_attr),
> >> +		pcaps[i].pattrs = kcalloc(count, sizeof(struct powercap_attr),
> >>  					  GFP_KERNEL);
> >>  		if (!pcaps[i].pattrs)
> >>  			goto out_pcaps_pattrs;
> >>  
> >> -		pcaps[i].pg.attrs = kcalloc(j + 1, sizeof(struct attribute *),
> >> +		pcaps[i].pg.attrs = kcalloc(count + 1,
> >> +					    sizeof(struct attribute *),
> >>  					    GFP_KERNEL);
> >>  		if (!pcaps[i].pg.attrs) {
> >>  			kfree(pcaps[i].pattrs);
> >>  			goto out_pcaps_pattrs;
> >>  		}
> >>  
> >> -		j = 0;
> >>  		pcaps[i].pg.name = kasprintf(GFP_KERNEL, "%pOFn", node);
> >> -		if (has_min) {
> >> -			powercap_add_attr(min, "powercap-min",
> >> -					  &pcaps[i].pattrs[j]);
> >> -			pcaps[i].pg.attrs[j] = &pcaps[i].pattrs[j].attr.attr;
> >> -			j++;
> >> -		}
> >> -
> >> -		if (has_max) {
> >> -			powercap_add_attr(max, "powercap-max",
> >> -					  &pcaps[i].pattrs[j]);
> >> -			pcaps[i].pg.attrs[j] = &pcaps[i].pattrs[j].attr.attr;
> >> -			j++;
> >> -		}
> >> +		for (j = 0; j < ARRAY_SIZE(powercap_strs); j++) {
> >> +			if (of_property_read_u32(node, powercap_strs[j], &id))
> >> +				continue;
> >>  
> >> -		if (has_cur) {
> >> -			powercap_add_attr(cur, "powercap-current",
> >> +			powercap_add_attr(id, powercap_strs[j],
> >>  					  &pcaps[i].pattrs[j]);
> >> -			pcaps[i].pattrs[j].attr.attr.mode |= 0220;
> >> -			pcaps[i].pattrs[j].attr.store = powercap_store;
> >>  			pcaps[i].pg.attrs[j] = &pcaps[i].pattrs[j].attr.attr;
> >> -			j++;
> >>  		}
> >>  
> >>  		if (sysfs_create_group(powercap_kobj, &pcaps[i].pg)) {
> >> -- 
> >> 1.8.3.1
> > 


      reply	other threads:[~2019-02-28  9:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-27  9:33 [PATCH] powernv: powercap: Add hard minimum powercap Shilpasri G Bhat
2019-02-28  4:44 ` Daniel Axtens
2019-02-28  5:55   ` Shilpasri G Bhat
2019-02-28  9:52     ` Gautham R Shenoy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190228095200.GB24751@in.ibm.com \
    --to=ego@linux.vnet.ibm.com \
    --cc=dja@axtens.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=shilpa.bhat@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).