diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/sysfs.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/sysfs.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/sysfs.c b/drivers/gpu/nvgpu/common/linux/sysfs.c index 6709285d..1f6da803 100644 --- a/drivers/gpu/nvgpu/common/linux/sysfs.c +++ b/drivers/gpu/nvgpu/common/linux/sysfs.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms and conditions of the GNU General Public License, | 5 | * under the terms and conditions of the GNU General Public License, |
@@ -504,6 +504,58 @@ static ssize_t elpg_enable_read(struct device *dev, | |||
504 | 504 | ||
505 | static DEVICE_ATTR(elpg_enable, ROOTRW, elpg_enable_read, elpg_enable_store); | 505 | static DEVICE_ATTR(elpg_enable, ROOTRW, elpg_enable_read, elpg_enable_store); |
506 | 506 | ||
507 | static ssize_t ldiv_slowdown_factor_store(struct device *dev, | ||
508 | struct device_attribute *attr, const char *buf, size_t count) | ||
509 | { | ||
510 | struct gk20a *g = get_gk20a(dev); | ||
511 | unsigned long val = 0; | ||
512 | int err; | ||
513 | |||
514 | if (kstrtoul(buf, 10, &val) < 0) { | ||
515 | nvgpu_err(g, "parse error for input SLOWDOWN factor\n"); | ||
516 | return -EINVAL; | ||
517 | } | ||
518 | |||
519 | if (val >= SLOWDOWN_FACTOR_FPDIV_BYMAX) { | ||
520 | nvgpu_err(g, "Invalid SLOWDOWN factor\n"); | ||
521 | return -EINVAL; | ||
522 | } | ||
523 | |||
524 | if (val == g->ldiv_slowdown_factor) | ||
525 | return count; | ||
526 | |||
527 | if (!g->power_on) { | ||
528 | g->ldiv_slowdown_factor = val; | ||
529 | } else { | ||
530 | err = gk20a_busy(g); | ||
531 | if (err) | ||
532 | return -EAGAIN; | ||
533 | |||
534 | g->ldiv_slowdown_factor = val; | ||
535 | |||
536 | if (g->ops.pmu.pmu_pg_init_param) | ||
537 | g->ops.pmu.pmu_pg_init_param(g, | ||
538 | PMU_PG_ELPG_ENGINE_ID_GRAPHICS); | ||
539 | |||
540 | gk20a_idle(g); | ||
541 | } | ||
542 | |||
543 | nvgpu_info(g, "ldiv_slowdown_factor is %x\n", g->ldiv_slowdown_factor); | ||
544 | |||
545 | return count; | ||
546 | } | ||
547 | |||
548 | static ssize_t ldiv_slowdown_factor_read(struct device *dev, | ||
549 | struct device_attribute *attr, char *buf) | ||
550 | { | ||
551 | struct gk20a *g = get_gk20a(dev); | ||
552 | |||
553 | return snprintf(buf, PAGE_SIZE, "%d\n", g->ldiv_slowdown_factor); | ||
554 | } | ||
555 | |||
556 | static DEVICE_ATTR(ldiv_slowdown_factor, ROOTRW, | ||
557 | ldiv_slowdown_factor_read, ldiv_slowdown_factor_store); | ||
558 | |||
507 | static ssize_t mscg_enable_store(struct device *dev, | 559 | static ssize_t mscg_enable_store(struct device *dev, |
508 | struct device_attribute *attr, const char *buf, size_t count) | 560 | struct device_attribute *attr, const char *buf, size_t count) |
509 | { | 561 | { |
@@ -1114,6 +1166,7 @@ int nvgpu_create_sysfs(struct device *dev) | |||
1114 | error |= device_create_file(dev, &dev_attr_elpg_enable); | 1166 | error |= device_create_file(dev, &dev_attr_elpg_enable); |
1115 | error |= device_create_file(dev, &dev_attr_mscg_enable); | 1167 | error |= device_create_file(dev, &dev_attr_mscg_enable); |
1116 | error |= device_create_file(dev, &dev_attr_emc3d_ratio); | 1168 | error |= device_create_file(dev, &dev_attr_emc3d_ratio); |
1169 | error |= device_create_file(dev, &dev_attr_ldiv_slowdown_factor); | ||
1117 | #ifdef CONFIG_TEGRA_DVFS | 1170 | #ifdef CONFIG_TEGRA_DVFS |
1118 | error |= device_create_file(dev, &dev_attr_fmax_at_vmin_safe); | 1171 | error |= device_create_file(dev, &dev_attr_fmax_at_vmin_safe); |
1119 | #endif | 1172 | #endif |