diff options
author | Steve Rogers <srogers@nvidia.com> | 2014-03-06 13:07:37 -0600 |
---|---|---|
committer | Timo Alho <talho@nvidia.com> | 2014-03-11 08:21:05 -0700 |
commit | b5a5a3fe138da1994dc0919458994644e0a1f401 (patch) | |
tree | 234c7ddd036205306ca750673b16df1b84cef7b3 /drivers/edp | |
parent | 08c8ad1c8c3833bac813fb65ef3131ddfedd0caa (diff) |
EDP: sysedp: Add mininimum budget control
Bug 1475120
Change-Id: I21be3f45e624412626b6f01f2ad04307f2911a8c
Signed-off-by: Steve Rogers <srogers@nvidia.com>
Reviewed-on: http://git-master/r/378467
Reviewed-by: Timo Alho <talho@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'drivers/edp')
-rw-r--r-- | drivers/edp/sysedp.c | 6 | ||||
-rw-r--r-- | drivers/edp/sysedp_debug.c | 40 | ||||
-rw-r--r-- | drivers/edp/sysedp_internal.h | 3 |
3 files changed, 44 insertions, 5 deletions
diff --git a/drivers/edp/sysedp.c b/drivers/edp/sysedp.c index 2eee57fc9c7b..97ff75938a86 100644 --- a/drivers/edp/sysedp.c +++ b/drivers/edp/sysedp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -31,6 +31,7 @@ LIST_HEAD(registered_consumers); static struct sysedp_platform_data *pdata; unsigned int avail_budget = 1000000; int margin; +int min_budget; void sysedp_set_avail_budget(unsigned int power) { @@ -57,7 +58,7 @@ void _sysedp_refresh(void) } limit = (int)avail_budget - pmax_sum - margin; - limit = limit >= 0 ? limit : 0; + limit = limit >= min_budget ? limit : min_budget; oc_relax = pmax_sum - pthres_sum; oc_relax = oc_relax >= 0 ? oc_relax : 0; @@ -212,6 +213,7 @@ static int sysedp_probe(struct platform_device *pdev) return -EINVAL; margin = pdata->margin; + min_budget = (pdata->min_budget >= 0) ? min_budget : 0; sysedp_init_sysfs(); sysedp_init_debugfs(); return 0; diff --git a/drivers/edp/sysedp_debug.c b/drivers/edp/sysedp_debug.c index 4cb321da5f0f..1e996d15efce 100644 --- a/drivers/edp/sysedp_debug.c +++ b/drivers/edp/sysedp_debug.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -38,7 +38,7 @@ static int sysedp_status_show(struct seq_file *file, void *data) } limit = (int)avail_budget - pmax_sum - margin; - limit = limit >= 0 ? limit : 0; + limit = limit >= min_budget ? limit : min_budget; oc_relax = pmax_sum - pthres_sum; oc_relax = oc_relax >= 0 ? oc_relax : 0; @@ -46,6 +46,7 @@ static int sysedp_status_show(struct seq_file *file, void *data) seq_printf(file, " avail_budget : %u\n", avail_budget); seq_printf(file, "- pmax_sum : %u\n", pmax_sum); seq_printf(file, "- margin : %d\n", margin); + seq_printf(file, "( minimum budget : %d)\n", min_budget); seq_printf(file, "= remaining (OC=1) : %d\n", limit); seq_printf(file, "+ oc_relax : %d\n", oc_relax); seq_printf(file, "= remaining (OC=0) : %d\n", limit + oc_relax); @@ -72,6 +73,36 @@ static const struct file_operations sysedp_status_fops = { .read = seq_read, }; + +static int sysedp_min_budget_set(void *data, u64 val) +{ + int old; + + old = min_budget; + min_budget = (((int)val) < 0) ? 0 : (int)val; + + if (old != min_budget) { + mutex_lock(&sysedp_lock); + /* Changes to min_budget require sysedp refresh */ + _sysedp_refresh(); + mutex_unlock(&sysedp_lock); + } + + return 0; +} + + +static int sysedp_min_budget_get(void *data, u64 *val) +{ + *val = min_budget; + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(sysedp_min_budget_fops, + sysedp_min_budget_get, + sysedp_min_budget_set, "%lld\n"); + + void sysedp_init_debugfs(void) { struct dentry *d; @@ -93,4 +124,9 @@ void sysedp_init_debugfs(void) d = debugfs_create_file("status", S_IRUGO, sysedp_debugfs_dir, NULL, &sysedp_status_fops); WARN_ON(IS_ERR_OR_NULL(d)); + + d = debugfs_create_file("min_budget", S_IRUGO | S_IWUSR, + sysedp_debugfs_dir, NULL, + &sysedp_min_budget_fops); + WARN_ON(IS_ERR_OR_NULL(d)); } diff --git a/drivers/edp/sysedp_internal.h b/drivers/edp/sysedp_internal.h index 96c3d9a918a6..cb725ac1d3c3 100644 --- a/drivers/edp/sysedp_internal.h +++ b/drivers/edp/sysedp_internal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -24,6 +24,7 @@ extern struct mutex sysedp_lock; extern struct dentry *edp_debugfs_dir; extern struct dentry *sysedp_debugfs_dir; extern int margin; +extern int min_budget; extern unsigned int avail_budget; extern unsigned int consumer_sum; extern struct list_head registered_consumers; |